Skip to content

Commit 9f19aa4

Browse files
committed
Get demo name automatically
1 parent c7326d0 commit 9f19aa4

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,58 @@
1-
# Sauer-Demo-Editor
2-
An in-game menu for scheduling actions during playback of Sauerbraten demos.
1+
# Cube 2 Sauerbraten Pseudo Demo Editor
2+
A menu for [Sauerbraten](http://sauerbraten.org) with functions to execute client commands at a specific time of a demo (replay), as well as functions to rewind and fast forward.
3+
4+
### Installation
5+
1. Download the [demoeditor.zip](https://github.com/SalatielSauer/Sauer-Demo-Editor/releases/latest) (without extracting it).
6+
2. Move it to the root folder of your Sauerbraten (the home folder or the main installation folder).
7+
3. Find your autoexec.cfg file or create a new one (also in one of the root folders), open it in a text editor and add the two commands:<br>
8+
`addzip demoeditor.zip; exec demoeditor.cfg`<br>
9+
The zip will be extracted internally and the configuration file (demoeditor.cfg) will be applied whenever you start the game.
10+
11+
To open the menu you can either type `/demoeditor` in the game's chat console (T key by default), or add an "edit" argument to the demo command (`/demo anydemoname edit`).
12+
13+
Alternatively to step 3 you can type the command `/notepad autoexec.cfg` during the game to open the built-in text editor.
14+
15+
### Tools
16+
<img src="packages/icons/de_skip_left.png" width="16px"/><img src="packages/icons/de_skip_right.png" width="16px"/> **Rewind and Fast-forward**:<br>
17+
You can use the arrow icons to control the current remaining time, and the gray sum/minus icons to control the selected target time.<br>
18+
![](https://raw.githubusercontent.com/SalatielSauer/misc/master/demoeditor_fastforward_rewind.gif)<br>
19+
The colors of the arrows represent a state:<br>
20+
- Invisible: Current remaining time equals selected time
21+
- Gray: Unable to rewind/forward
22+
- Orange: Able to rewind/forward<br>
23+
24+
<img src="packages/icons/de_plus.png" width="16px"/> **Adding Actions**:<br>
25+
You can use the green sum icon to add actions to the current project, just select the time you want and fill the text field with any command.<br>
26+
![](https://raw.githubusercontent.com/SalatielSauer/misc/master/demoeditor_add_actions.gif)<br>
27+
28+
<img src="packages/icons/de_gear.png" width="16px"/> **Starting Actions**:<br>
29+
Actions are not executed by default, you can enable or disable them using the gear icon.<br>
30+
![](https://raw.githubusercontent.com/SalatielSauer/misc/master/demoeditor_start_actions.gif)<br>
31+
Each color of the gear represents a state:<br>
32+
- Gray: Actions are disabled and game is paused
33+
- Yellow: Actions are enabled and game is paused
34+
- Red: Actions are disabled and game is running
35+
- Green: Actions are enabled and game is running<br>
36+
37+
<img src="packages/icons/de_minus.png" width="16px"/> **Removing Actions**:<br>
38+
You can use the red minus icon to remove individual actions, or the gear icon submenu to remove all actions.<br>
39+
![](https://raw.githubusercontent.com/SalatielSauer/misc/master/demoeditor_remove_actions.gif)<br>
40+
41+
<img src="packages/icons/de_folder.png" width="16px"/> **Saving and Loading Actions**:<br>
42+
The folder icon allows you to save or load actions from an external (.cfg) file.<br>
43+
![](https://raw.githubusercontent.com/SalatielSauer/misc/master/demoeditor_save_load_actions.gif)<br>
44+
The demo/project name is added automatically, if no path is specified, the .cfg file will be saved in the $demodir, next to the .dmo file.<br>
45+
The colors of the save button also represent a state:<br>
46+
- Red: The specified demo name does not exist
47+
- Yellow: There is already a .cfg file available with the demo name
48+
- White: The demo exists and there is no .cfg file available
49+
50+
If you prefer, you can edit the actions configuration file manually following this structure:
51+
```
52+
_de_echo [Loaded 3 actions by unnamed]
53+
_de_actions_time = [[540] [480] [443]]
54+
_de_actions_timereadable = [[9 0] [8 0] [7 23]]
55+
_de_actions_command = [[echo "action 1"] [echo "action 2"] [echo "action 3"]]
56+
```
57+
For an action file to be automatically detected when loading a demo, it must be in the same folder and have the same name as the .dmo.
58+
If you want to load an action file manually, just apply the file with `/exec actionfile.cfg` or change the project name using the interface.

demoeditor.cfg

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,17 @@ newgui pseudodemoeditor [
218218
if (!=s $_de_input_demoname "") [
219219
if $_de_validdemoname [
220220
demo $_de_input_demoname
221-
] [_de_echo (concat "^f7Demo^f8" $_de_input_demoname "^f7not found.")]
221+
] [
222+
local demonamebuff
223+
demonamebuff = $_de_input_demoname
224+
_de_echo (concat "^f7Project^f8" $demonamebuff "^f7does not have a demo file with the same name.")
225+
demo $_de_lastvaliddemo
226+
_de_input_demonamebuff = $demonamebuff
227+
_de_input_demoname = $demonamebuff
228+
_de_refreshdemovalidity
229+
]
222230
] [
223-
_de_echo "^f7You can't rewind without setting the ^f5demo name^f~."
231+
_de_echo "^f7You can't rewind without setting the ^f5project name^f~."
224232
]
225233
]
226234
seekdemo (concatword "-" $_de_input_minutes ":" $_de_input_seconds)
@@ -409,9 +417,9 @@ newgui pseudodemoeditor [
409417
guititle (concatword "^f7" $_de_message)
410418
guialign 0 [
411419
guistayopen [
412-
_de_icon "de_confirm.png" [_de_confirmaction; _de_popupvisible = 0] 0.5 "0/1/0"
420+
_de_icon "de_confirm.png" [_de_popupvisible = 0; _de_curmillis = $_de_savedmillis; _de_confirmaction] 0.5 "0/1/0"
413421
guistrut 1
414-
_de_icon "de_cancel.png" [_de_popupvisible = 0] 0.5 "0.9/0.2/0.2"
422+
_de_icon "de_cancel.png" [_de_popupvisible = 0; _de_curmillis = $_de_savedmillis] 0.5 "0.9/0.2/0.2"
415423
]
416424
]
417425
guistayopen [if $_de_confirmgui [_de_confirmgui]]

0 commit comments

Comments
 (0)