Demo_Rename.diff
| qcsrc/dpdefs/csprogsdefs.qc | ||
|---|---|---|
| 435 | 435 |
string(string s) strzone = #118; |
| 436 | 436 |
void(string s) strunzone = #119; |
| 437 | 437 | |
| 438 |
// Colin |
|
| 439 |
float(string from, string to) rename = #642; |
|
| 440 | ||
| 438 | 441 |
// FTEQW range #200-#299 |
| 439 | 442 | |
| 440 | 443 |
float(float number, float quantity) bitshift = #218; |
| 441 | 444 |
Modified qcsrc/dpdefs/dpextensions.qc |
| qcsrc/dpdefs/dpextensions.qc | ||
|---|---|---|
| 2115 | 2115 |
vector(string s) stov = #117; // returns vector value from a string |
| 2116 | 2116 |
string(string s, ...) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often) |
| 2117 | 2117 |
void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!) |
| 2118 | ||
| 2119 |
// Colin |
|
| 2120 |
float(string from, string to) rename = #642; |
|
| 2121 | ||
| 2118 | 2122 |
//constants: |
| 2119 | 2123 |
float FILE_READ = 0; |
| 2120 | 2124 |
float FILE_APPEND = 1; |
| 2121 | 2125 |
Modified qcsrc/dpdefs/menudefs.qc |
| qcsrc/dpdefs/menudefs.qc | ||
|---|---|---|
| 244 | 244 |
string fgets(float fhandle) = #50; |
| 245 | 245 |
void fputs(float fhandle, string s) = #51; |
| 246 | 246 | |
| 247 |
// Colin |
|
| 248 |
float rename(string from, string to) = #642; |
|
| 249 | ||
| 247 | 250 |
float strlen(string s) = #52; |
| 248 | 251 |
string strcat(string s1,string s2,...) = #53; |
| 249 | 252 |
string substring(string s, float start, float length) = #54; |
| 250 | 253 |
Modified qcsrc/menu/classes.c |
| qcsrc/menu/classes.c | ||
|---|---|---|
| 86 | 86 |
#include "xonotic/dialog_multiplayer_playersetup_view.c" |
| 87 | 87 |
#include "xonotic/dialog_multiplayer_playersetup_weapons.c" |
| 88 | 88 |
#include "xonotic/weaponslist.c" |
| 89 |
// Added by Colin |
|
| 90 |
#include "xonotic/dialog_multiplayer_demo_demoinfo.c" |
|
| 89 | 91 |
#include "xonotic/dialog_multiplayer_demo.c" |
| 90 | 92 |
#include "xonotic/demolist.c" |
| 91 | 93 |
#include "xonotic/colorpicker.c" |
| 92 | 94 |
Modified qcsrc/menu/xonotic/demolist.c |
| qcsrc/menu/xonotic/demolist.c | ||
|---|---|---|
| 22 | 22 |
|
| 23 | 23 |
ATTRIB(XonoticDemoList, lastClickedDemo, float, -1) |
| 24 | 24 |
ATTRIB(XonoticDemoList, lastClickedTime, float, 0) |
| 25 |
ATTRIB(XonoticDemoList, filterString, string, string_null)
|
|
| 25 |
ATTRIB(XonoticDemoList, filterString, string, string_null) |
|
| 26 | 26 |
ENDCLASS(XonoticDemoList) |
| 27 | 27 | |
| 28 | 28 |
entity makeXonoticDemoList(); |
| 29 | 29 |
void StartDemo_Click(entity btn, entity me); |
| 30 | 30 |
void TimeDemo_Click(entity btn, entity me); |
| 31 |
void InfoDemo_Click(entity btn, entity dlist); |
|
| 32 | ||
| 31 | 33 |
void DemoList_Filter_Change(entity box, entity me); |
| 32 | 34 |
#endif |
| 33 | 35 | |
| ... | ... | |
| 44 | 46 |
void XonoticDemoList_configureXonoticDemoList(entity me) |
| 45 | 47 |
{
|
| 46 | 48 |
me.configureXonoticListBox(me); |
| 47 |
me.getDemos(me);
|
|
| 49 |
me.getDemos(me); |
|
| 48 | 50 |
} |
| 49 | 51 | |
| 50 | 52 |
string XonoticDemoList_demoName(entity me, float i ) |
| ... | ... | |
| 62 | 64 |
|
| 63 | 65 |
if(me.filterString) |
| 64 | 66 |
//subdirectory in filterString allowed |
| 65 |
s=strcat("demos/*", me.filterString, "*.dem");
|
|
| 67 |
s=strcat("demos/*", me.filterString, "*.dem");
|
|
| 66 | 68 |
else |
| 67 | 69 |
s="demos/*.dem"; |
| 68 | 70 |
|
| ... | ... | |
| 128 | 130 |
void XonoticDemoList_startDemo(entity me) |
| 129 | 131 |
{
|
| 130 | 132 |
string s; |
| 131 |
s = me.demoName(me,me.selectedItem); |
|
| 133 |
s = me.demoName(me, me.selectedItem);
|
|
| 132 | 134 |
localcmd("playdemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
|
| 133 | 135 |
} |
| 134 | 136 | |
| ... | ... | |
| 144 | 146 |
localcmd("timedemo \"demos/", s, ".dem\" \nwait \ntogglemenu\n");
|
| 145 | 147 |
} |
| 146 | 148 | |
| 149 |
// Opens up a dialog for additional information about the selected |
|
| 150 |
// demo file |
|
| 151 |
void InfoDemo_Click(entity btn, entity dlist) |
|
| 152 |
{
|
|
| 153 |
main.demoInfoDialog.loadDemoInfo(main.demoInfoDialog, dlist); |
|
| 154 |
DialogOpenButton_Click(dlist, main.demoInfoDialog); |
|
| 155 |
} |
|
| 156 | ||
| 147 | 157 |
void XonoticDemoList_clickListBoxItem(entity me, float i, vector where) |
| 148 | 158 |
{
|
| 149 | 159 |
if(i == me.lastClickedDemo) |
| ... | ... | |
| 166 | 176 |
else |
| 167 | 177 |
return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift); |
| 168 | 178 |
} |
| 169 |
#endif |
|
| 170 | 179 | |
| 180 |
#endif |
|
| 171 | 181 |
Modified qcsrc/menu/xonotic/dialog_multiplayer_demo.c |
| qcsrc/menu/xonotic/dialog_multiplayer_demo.c | ||
|---|---|---|
| 42 | 42 |
me.TD(me, me.rows - 4, me.columns, dlist); |
| 43 | 43 |
|
| 44 | 44 |
me.gotoRC(me, me.rows - 1, 0); |
| 45 |
me.TD(me, 1, me.columns / 2, e = makeXonoticButton(_("Timedemo"), '0 0 0'));
|
|
| 45 |
me.TD(me, 1, me.columns / 3, e = makeXonoticButton(_("Timedemo"), '0 0 0'));
|
|
| 46 | 46 |
e.onClick = TimeDemo_Click; |
| 47 | 47 |
e.onClickEntity = dlist; |
| 48 |
me.TD(me, 1, me.columns / 2, e = makeXonoticButton(ZCTX(_("DEMO^Play")), '0 0 0'));
|
|
| 48 |
me.TD(me, 1, me.columns / 3, e = makeXonoticButton(ZCTX(_("Play")), '0 0 0'));
|
|
| 49 | 49 |
e.onClick = StartDemo_Click; |
| 50 |
e.onClickEntity = dlist; |
|
| 50 |
e.onClickEntity = dlist; |
|
| 51 |
me.TD(me, 1, me.columns / 3, e = makeXonoticButton(_("Info..."), '0 0 0'));
|
|
| 52 |
e.onClick = InfoDemo_Click; |
|
| 53 |
e.onClickEntity = dlist; |
|
| 51 | 54 |
} |
| 52 | 55 |
#endif |
| 53 | 56 |
New qcsrc/menu/xonotic/dialog_multiplayer_demo_demoinfo.c |
| qcsrc/menu/xonotic/dialog_multiplayer_demo_demoinfo.c | ||
|---|---|---|
| 1 |
// NOTE: When user presses "Save" dont close the Dialog. Instead, update! |
|
| 2 |
#ifdef INTERFACE |
|
| 3 |
CLASS(XonoticDemoInfoDialog) EXTENDS(XonoticDialog) |
|
| 4 |
METHOD(XonoticDemoInfoDialog, fill, void(entity)) |
|
| 5 |
METHOD(XonoticDemoInfoDialog, loadDemoInfo, void(entity, entity)) |
|
| 6 |
ATTRIB(XonoticDemoInfoDialog, title, string, _("Demo Information"))
|
|
| 7 |
// ATTRIB(XonoticDemoInfoDialog, color, vector, SKINCOLOR_DIALOG_DEMOINFO) |
|
| 8 |
ATTRIB(XonoticDemoInfoDialog, intendedWidth, float, 0.8) |
|
| 9 |
ATTRIB(XonoticDemoInfoDialog, rows, float, 18) |
|
| 10 |
ATTRIB(XonoticDemoInfoDialog, columns, float, 6.2) |
|
| 11 |
|
|
| 12 |
ATTRIB(XonoticDemoInfoDialog, currentDemoName, string, string_null) |
|
| 13 | ||
| 14 |
ATTRIB(XonoticDemoInfoDialog, demoNameLabel, entity, NULL) |
|
| 15 |
ATTRIB(XonoticDemoInfoDialog, demolist, entity, NULL) |
|
| 16 | ||
| 17 |
// Used to change the demo name. |
|
| 18 |
ATTRIB(XonoticDemoInfoDialog, newDemoName, string, string_null) |
|
| 19 |
ATTRIB(XonoticDemoInfoDialog, demoNameBox, entity, NULL) |
|
| 20 |
ENDCLASS(XonoticDemoInfoDialog) |
|
| 21 | ||
| 22 |
void PlayDemo_Click(entity btn, entity me); |
|
| 23 |
#endif |
|
| 24 | ||
| 25 |
#ifdef IMPLEMENTATION |
|
| 26 |
void XonoticDemoInfoDialog_loadDemoInfo(entity me, entity dlist) |
|
| 27 |
{
|
|
| 28 |
// ==================================== |
|
| 29 |
// First clear and unzone the strings |
|
| 30 |
// ==================================== |
|
| 31 |
if(me.currentDemoName) |
|
| 32 |
strunzone(me.currentDemoName); |
|
| 33 |
me.currentDemoName = string_null; |
|
| 34 | ||
| 35 |
|
|
| 36 |
// ========================== |
|
| 37 |
// Now, fill in the strings |
|
| 38 |
// ========================== |
|
| 39 |
me.currentDemoName = strzone(dlist.demoName(dlist, dlist.selectedItem)); |
|
| 40 |
me.demoNameLabel.setText(me.demoNameLabel, me.currentDemoName); |
|
| 41 |
me.demoNameBox.setText(me.demoNameBox, me.currentDemoName); |
|
| 42 |
|
|
| 43 |
dprint("Current demo: ", me.currentDemoName, "\n");
|
|
| 44 |
|
|
| 45 |
// Save the demo list for updating |
|
| 46 |
me.demolist = dlist; |
|
| 47 |
} |
|
| 48 | ||
| 49 |
void XonoticDemoInfoDialog_Clear(entity me) |
|
| 50 |
{
|
|
| 51 |
// ==================================== |
|
| 52 |
// First clear and unzone the strings |
|
| 53 |
// ==================================== |
|
| 54 |
if(me.newDemoName) |
|
| 55 |
strunzone(me.newDemoName); |
|
| 56 |
me.newDemoName = string_null; |
|
| 57 |
} |
|
| 58 | ||
| 59 |
void PlayDemo_Click(entity btn, entity me) |
|
| 60 |
{
|
|
| 61 |
localcmd("playdemo \"demos/", me.currentDemoName, ".dem\" \nwait \ntogglemenu\n");
|
|
| 62 |
} |
|
| 63 | ||
| 64 |
void XonoticDemoInfoDialog_Save(entity btn, entity me) |
|
| 65 |
{
|
|
| 66 |
float rename_error; |
|
| 67 |
string oldname; |
|
| 68 |
string newname; |
|
| 69 |
// Colin: when the user clicks OK the newDemoName has to be |
|
| 70 |
// applied before strun and closeDialog can be run. |
|
| 71 |
|
|
| 72 |
// 1. Change/Save the new demo name |
|
| 73 |
|
|
| 74 |
oldname = strcat("demos/", me.currentDemoName, ".dem");
|
|
| 75 |
newname = strcat("demos/", me.demoNameBox.text, ".dem");
|
|
| 76 |
|
|
| 77 |
rename_error = rename(oldname, newname); |
|
| 78 |
if(rename_error < 0.0) {
|
|
| 79 |
dprint("Save: could not save the new name.");
|
|
| 80 |
return; |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
// 2. Update the demolist |
|
| 84 |
me.demolist.getDemos(me.demolist); |
|
| 85 |
|
|
| 86 |
// 3. Close the dialog |
|
| 87 |
DialogCloseButton_Click(me, main.demoInfoDialog); |
|
| 88 |
} |
|
| 89 | ||
| 90 |
void XonoticDemoInfoDialog_Cancel(entity btn, entity me) |
|
| 91 |
{
|
|
| 92 |
// Colin: when the user closes the demo info dialog, the |
|
| 93 |
// newDemoName string has to be cleared before closing |
|
| 94 |
|
|
| 95 |
// 1. Clear the newDemoName string |
|
| 96 |
XonoticDemoInfoDialog_Clear(me); |
|
| 97 |
|
|
| 98 |
// 2. Close the demoInfoDialog |
|
| 99 |
DialogCloseButton_Click(me, main.demoInfoDialog); |
|
| 100 |
} |
|
| 101 | ||
| 102 | ||
| 103 |
void XonoticDemoInfoDialog_fill(entity me) |
|
| 104 |
{
|
|
| 105 |
entity e, box, btn; |
|
| 106 | ||
| 107 |
me.TR(me); |
|
| 108 |
me.TR(me); |
|
| 109 |
me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Name:")));
|
|
| 110 |
me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0, "")); |
|
| 111 |
e.allowCut = 1; |
|
| 112 |
me.demoNameLabel = e; |
|
| 113 |
|
|
| 114 |
me.TR(me); |
|
| 115 |
me.TD(me, 1, me.columns - 0.6 * 4 - 0.4, me.demoNameBox = makeXonoticInputBox(0, string_null)); |
|
| 116 |
|
|
| 117 |
me.gotoRC(me, me.rows - 1, 0); |
|
| 118 |
me.TD(me, 1, me.columns/3, e = makeXonoticButton(_("Play"), '0 0 0'));
|
|
| 119 |
e.onClick = PlayDemo_Click; |
|
| 120 |
e.onClickEntity = me; |
|
| 121 |
me.TD(me, 1, me.columns/3, e = makeXonoticButton(_("Cancel"), '0 0 0'));
|
|
| 122 |
e.onClick = XonoticDemoInfoDialog_Cancel; |
|
| 123 |
e.onClickEntity = me; |
|
| 124 |
me.TD(me, 1, me.columns/3, e = makeXonoticButton(_("Save"), '0 0 0'));
|
|
| 125 |
e.onClick = XonoticDemoInfoDialog_Save; |
|
| 126 |
e.onClickEntity = me; |
|
| 127 |
} |
|
| 128 |
#endif |
|
| 0 | 129 |
Modified qcsrc/menu/xonotic/mainwindow.c |
| qcsrc/menu/xonotic/mainwindow.c | ||
|---|---|---|
| 16 | 16 |
ATTRIB(MainWindow, crosshairDialog, entity, NULL) |
| 17 | 17 |
ATTRIB(MainWindow, hudDialog, entity, NULL) |
| 18 | 18 |
ATTRIB(MainWindow, hudconfirmDialog, entity, NULL) |
| 19 |
ATTRIB(MainWindow, demoInfoDialog, entity, NULL) |
|
| 19 | 20 |
ATTRIB(MainWindow, mainNexposee, entity, NULL) |
| 20 | 21 |
ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND) |
| 21 | 22 |
ATTRIB(MainWindow, dialogToShow, entity, NULL) |
| ... | ... | |
| 188 | 189 |
me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); |
| 189 | 190 |
|
| 190 | 191 | |
| 192 |
// dialog used by multiplayer/demo |
|
| 193 |
me.demoInfoDialog = i = spawnXonoticDemoInfoDialog(); |
|
| 194 |
i.configureDialog(i); |
|
| 195 |
me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); |
|
| 196 |
|
|
| 197 |
|
|
| 191 | 198 |
// mutator dialogs |
| 192 | 199 |
i = spawnXonoticSandboxToolsDialog(); |
| 193 | 200 |
i.configureDialog(i); |