Skip to content

Commit

Permalink
Merge branch 'DFHack:master' into update-stonesense-authors
Browse files Browse the repository at this point in the history
  • Loading branch information
realSquidCoder authored Jan 19, 2025
2 parents a638954 + e1e5b95 commit c8a110a
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 150 deletions.
17 changes: 17 additions & 0 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ namespace {
return;
}

if (line.find("[CLOSEONESC") != string::npos) {
string result = parseStrFromLine("CLOSEONESC", line);
ssConfig.closeOnEsc = (result == "YES");
}

if (line.find("[WIDTH") != string::npos) {
int width = parseIntFromLine("WIDTH", line);
ssState.ScreenW = width;
Expand Down Expand Up @@ -168,6 +173,18 @@ namespace {
string result = parseStrFromLine("SHOW_CREATURE_NAMES", line);
ssConfig.show_creature_names = (result == "YES");
}
if (line.find("[SHOW_CREATURE_MOODS") != string::npos) {
string result = parseStrFromLine("SHOW_CREATURE_MOODS", line);
ssConfig.show_creature_moods = (result == "YES");
}
if (line.find("[SHOW_CREATURE_JOBS") != string::npos) {
string result = parseStrFromLine("SHOW_CREATURE_JOBS", line);
ssConfig.show_creature_jobs = (result == "YES");
}
if (line.find("[SHOW_CREATURE_PROFESSIONS") != string::npos) {
int value = parseIntFromLine("SHOW_CREATURE_PROFESSIONS", line);
ssConfig.show_creature_professions = value;
}
if (line.find("[NAMES_USE_NICKNAME") != string::npos) {
string result = parseStrFromLine("NAMES_USE_NICKNAME", line);
ssConfig.names_use_nick = (result == "YES");
Expand Down
6 changes: 5 additions & 1 deletion GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,11 @@ void paintboard()
ssTimers.frame_total = (donetime - ssTimers.prev_frame_time)*0.1 + ssTimers.frame_total*0.9;
ssTimers.prev_frame_time = donetime;

if (ssConfig.show_announcements) {
al_hold_bitmap_drawing(true);
draw_announcements(font, ssState.ScreenW, ssState.ScreenH - 20, ALLEGRO_ALIGN_RIGHT, df::global::world->status.announcements);
al_hold_bitmap_drawing(false);
}
if(ssConfig.show_keybinds){
std::string *keyname, *actionname;
keyname = actionname = NULL;
Expand All @@ -900,7 +905,6 @@ void paintboard()

drawDebugCursor(segment);

draw_announcements(font, ssState.ScreenW, ssState.ScreenH - 20, ALLEGRO_ALIGN_RIGHT, df::global::world->status.announcements);
drawAdvmodeMenuTalk(font, 5, ssState.ScreenH - 5);

if(ssConfig.debug_mode) {
Expand Down
3 changes: 3 additions & 0 deletions Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ action_name_mapper actionnamemap[] = {
{"TOGGLE_STOCKS", action_togglestockpiles},
{"TOGGLE_ZONES", action_togglezones},
{"TOGGLE_OCCLUSION", action_toggleocclusion},
{"TOGGLE_FOG",action_togglefog},
{"TOGGLE_CREATURE_MOODS", action_togglecreaturemood},
{"TOGGLE_CREATURE_PROFS", action_togglecreatureprof},
{"TOGGLE_CREATURE_JOBS", action_togglecreaturejob},
Expand All @@ -198,6 +199,8 @@ action_name_mapper actionnamemap[] = {
{"TOGGLE_SHOW_HIDDEN_TILES", action_toggleshowhidden},
{"TOGGLE_OSD", action_toggleosd},
{"TOGGLE_KEYBINDS", action_togglekeybinds},
{"TOGGLE_ANNOUNCEMENTS", action_toggleannouncements},
{"TOGGLE_DEBUG", action_toggledebug},
{"INCR_ZOOM", action_incrzoom},
{"DECR_ZOOM", action_decrzoom},
{"SCREENSHOT", action_screenshot},
Expand Down
14 changes: 14 additions & 0 deletions UserInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ void action_toggleocclusion(uint32_t keymod)
timeToReloadSegment = true;
}

void action_togglefog(uint32_t keymod)
{
ssConfig.fogenable = !ssConfig.fogenable;
}

void action_togglecreaturemood(uint32_t keymod)
{
ssConfig.show_creature_moods = !ssConfig.show_creature_moods;
Expand Down Expand Up @@ -382,6 +387,15 @@ void action_togglekeybinds(uint32_t keymod){
ssConfig.show_keybinds = !ssConfig.show_keybinds;
}

void action_toggleannouncements(uint32_t keymod) {
ssConfig.show_announcements = !ssConfig.show_announcements;
}

void action_toggledebug(uint32_t keymod)
{
ssConfig.debug_mode = !ssConfig.debug_mode;
}

void action_incrzoom(uint32_t keymod)
{
ssConfig.zoom++;
Expand Down
3 changes: 3 additions & 0 deletions UserInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void action_toggledesignations(uint32_t keymod);
void action_togglestockpiles(uint32_t keymod);
void action_togglezones(uint32_t keymod);
void action_toggleocclusion(uint32_t keymod);
void action_togglefog(uint32_t keymod);
void action_togglecreaturemood(uint32_t keymod);
void action_togglecreatureprof(uint32_t keymod);
void action_togglecreaturejob(uint32_t keymod);
Expand All @@ -24,7 +25,9 @@ void action_toggleshadehidden(uint32_t keymod);
void action_toggleshowhidden(uint32_t keymod);
void action_togglecreaturenames(uint32_t keymod);
void action_toggleosd(uint32_t keymod);
void action_toggledebug(uint32_t keymod);
void action_togglekeybinds(uint32_t keymod);
void action_toggleannouncements(uint32_t keymod);
void action_incrzoom(uint32_t keymod);
void action_decrzoom(uint32_t keymod);
void action_screenshot(uint32_t keymod);
Expand Down
2 changes: 2 additions & 0 deletions commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ struct GameConfiguration {
bool show_stockpiles;
bool show_designations;
bool show_osd;
bool show_announcements;
bool show_keybinds;
bool closeOnEsc;
bool single_layer_view;
bool shade_hidden_tiles;
bool show_hidden_tiles;
Expand Down
10 changes: 8 additions & 2 deletions configs/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Please note, these keywords are case sensitive for now.

--Interface--

Sets whether hitting Esc will close the window, in addition to being able
to use the close window button. (YES or NO)
[CLOSEONESC:YES]

Sets the width and height of the application in pixels.
[WIDTH:800]
[HEIGHT:600]
Expand Down Expand Up @@ -92,8 +96,10 @@ Sets Stonesense in debug mode. Adds additional information to displays.
Sets the debug cursor to follow the cursor from DF when it is there.
[FOLLOW_DF_CURSOR:YES]

Shows creatures names floating above their sprites. (Toggle with 'n')
[SHOW_CREATURE_NAMES:YES]
Shows creatures info floating above their sprites.
[SHOW_CREATURE_NAMES:NO]
[SHOW_CREATURE_MOODS:NO]
[SHOW_CREATURE_JOBS:NO]

Options to control how names are displayed (if SHOW_CREATURE_NAMES is set)
[NAMES_USE_NICKNAME:YES]
Expand Down
17 changes: 17 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,25 @@ Template for new versions:

## New Features

## Fixes

## Misc Improvements

## Removed

# 50.15-r2

## New Features
- `stonesense`: added hotkey to toggle fog ``;`` (default keybinding)
- `stonesense`: added hotkey to toggle announcements: ``a`` (default keybinding)
- `stonesense`: added hotkey to toggle debug mode: ``~`` (default keybinding)
- `stonesense`: added init file config to show announcements (on by default)
- `stonesense`: added init file config for whether Esc is recognized for closing the stonesense window (on by default to match previous behavior)
- `stonesense`: added init file config for whether creature moods and jobs are displayed (off by default)

## Fixes
- `stonesense`: fixed crash when maximizing or resizing the window
- `stonesense`: fixed crash when turning the onscreen display (OSD) layer off

## Misc Improvements
- `stonesense`: changed announcements to be right-aligned and limited to only show the most recent 10 announcements
Expand Down
5 changes: 4 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL
}
if(event.keyboard.display != display) {
break;
} else if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
}
else if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE && ssConfig.closeOnEsc) {
return;
} else {
doKeys(event.keyboard.keycode, event.keyboard.modifiers);
Expand Down Expand Up @@ -395,6 +396,8 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms)
color_ostream_proxy out(Core::getInstance().getConsole());
out.print("Stonesense launched\n");

ssConfig.closeOnEsc = true;
ssConfig.show_announcements = true;
ssConfig.debug_mode = false;
ssConfig.hide_outer_tiles = false;
ssConfig.shade_hidden_tiles = true;
Expand Down
Loading

0 comments on commit c8a110a

Please sign in to comment.