Skip to content

Commit

Permalink
Added 'noteshot' console command for taking screenshots alongside notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JadingTsunami committed Mar 28, 2024
1 parent 18a948c commit c25ba71
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Install [PrBoom-Plus](https://github.com/coelckers/prboom-plus) and place the bi
* Jot down quick notes while playtesting. Notes go into a dated text file in the current working directory.
* Each note lists the time, all loaded WAD files, player position, and an optional user-supplied message on the console.
* Example: `note demon is stuck in the wall here`.
* **NEW**: `noteshot` will include screenshots of the screen and automap. Useful if you will post your feedback to forum threads, discord channels, etc.
* Time Warp: Travel forward and backwards in time while playing.
* Time travel even if you died or made it to a new level.
* Enable Time Warp in the PrBoomX options screen
Expand Down Expand Up @@ -82,6 +83,7 @@ Install [PrBoom-Plus](https://github.com/coelckers/prboom-plus) and place the bi
- `kill <class>` (see also [Actor Names](https://github.com/JadingTsunami/prboomX#actor-names))
- `give <thing>`
- `note <message>` (write notes to a dated text file, useful for quick notes while playtesting)
- `noteshot <message>` (same as above, and take screenshots with and without the automap)
- `mdk`
- `plat_skip` (when enabled, press the "use" key to trigger a lift you're standing in to raise immediately)
- `bind [key] [command]` (bind any [key](https://github.com/JadingTsunami/prboomX#bindable-special-key-names) to any one or more console commands)
Expand Down
75 changes: 73 additions & 2 deletions prboom2/src/c_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,61 @@ static mobj_t* FindNextMobj(fixed_t* x, fixed_t* y, mobj_t* startmobj, int flags
static dboolean IsMobjKey(mobj_t* mo);
static dboolean IsMobjInThinkerList(mobj_t* mo);

typedef struct tick_event_t {
int ticks_left;
void (*callback)(void);
struct tick_event_t* next;
} tick_event_t;

tick_event_t* tick_head;

void C_Ticker()
{
tick_event_t* t = tick_head;
tick_event_t* tprev = NULL;

while (t) {
t->ticks_left--;
if (t->ticks_left <= 0) {
tick_event_t* tp = NULL;
if (t->callback)
t->callback();
if (tprev) {
tprev->next = t->next;
} else {
tick_head = t->next;
}
tp = t;
t = t->next;
free(tp);
} else {
tprev = t;
t = t->next;
}
}
}

static void C_schedule(int ticks_from_now, void (*callback)(void))
{
tick_event_t* t;
tick_event_t* tend = tick_head;

t = malloc(sizeof(tick_event_t));
if (!t) return;

t->ticks_left = MAX(1, ticks_from_now);
t->callback = callback;
t->next = NULL;

while (tend && tend->next)
tend = tend->next;

if (tend)
tend->next = t;
else
tick_head = t;
}

/* Parses arguments out from a string using spaces as separators.
* Returns the number of arguments successfully parsed.
*
Expand Down Expand Up @@ -488,7 +543,7 @@ static void C_give(char* cmd)
}

extern hu_textline_t w_title;
static void C_note(char* cmd)
static void C_note_internal(char* cmd, dboolean printmsg)
{
time_t t = time(NULL);
struct tm tm = *localtime(&t);
Expand Down Expand Up @@ -537,14 +592,20 @@ static void C_note(char* cmd)
fprintf(f, "%s", cmd);
fprintf(f, "\n\n");
fclose(f);
doom_printf("Note written to %s", notefile);
if (printmsg)
doom_printf("Note written to %s", notefile);
} else {
/* print error even if printmsg not set */
doom_printf("Couldn't open note file %s", notefile);
}
}
free(notefile);
}

static void C_note(char* cmd)
{
C_note_internal(cmd, true);
}

static void C_mdk(char* cmd)
{
Expand Down Expand Up @@ -1218,6 +1279,15 @@ static void C_quicksave(char* cmd)
M_QuickSave();
}

static void C_noteshot(char* cmd)
{
C_note_internal(cmd, false);
C_schedule(1, C_screenshot);
C_schedule(2, C_mapfollow);
C_schedule(4, C_screenshot);
C_schedule(5, C_mapfollow);
}

command command_list[] = {
{"noclip", C_noclip},
{"noclip2", C_noclip2},
Expand All @@ -1237,6 +1307,7 @@ command command_list[] = {
{"warp", C_map},
{"give", C_give},
{"note", C_note},
{"noteshot", C_noteshot},
{"mdk", C_mdk},
{"bind", C_bind},
{"unbind", C_unbind},
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/c_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dboolean C_UnregisterBind(int keycode, evtype_t type);
void C_SaveSettings();
void C_LoadSettings();
const char* C_CommandComplete(const char* partial);
void C_Ticker();

typedef struct _command {
const char* name;
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#include "SDL.h"
#include "c_cvar.h"
#include "i_sound.h"
#include "c_cmd.h"

#include "m_io.h"

Expand Down Expand Up @@ -1321,6 +1322,7 @@ void G_Ticker (void)
ST_Ticker ();
HU_Ticker ();
G_TimeWarpTicker();
C_Ticker();
break;

case GS_INTERMISSION:
Expand Down

0 comments on commit c25ba71

Please sign in to comment.