Skip to content

Commit

Permalink
Merge branch 'master' into squid-DRY-cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
realSquidCoder authored Feb 9, 2025
2 parents e1d09d7 + 8d445c7 commit a7cf88b
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 28 deletions.
4 changes: 4 additions & 0 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ namespace {
}
}

bool isViewTracking() {
auto& ssConfig = stonesenseState.ssConfig;
return ssConfig.config.track_mode != Config::TRACKING_NONE;
}

bool loadConfigFile()
{
Expand Down
1 change: 1 addition & 0 deletions Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ struct action_name_mapper {
void (*func)(uint32_t);
};

bool isViewTracking();
bool loadConfigFile();
std::optional<std::string> trim_line(std::string line);
1 change: 0 additions & 1 deletion ContentBuildingReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "df/building_def.h"
#include "df/world.h"
#include "df/world_raws.h"

using std::string;

Expand Down
3 changes: 1 addition & 2 deletions ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "df/material.h"
#include "df/tissue_style_raw.h"
#include "df/world.h"
#include "df/world_raws.h"

using std::vector;
using std::string;
Expand Down Expand Up @@ -705,7 +704,7 @@ void ContentLoader::flushCreatureConfig()
style_indices.clear();
}

void ContentLoader::gatherStyleIndices(df::world_raws * raws)
void ContentLoader::gatherStyleIndices(df::world::T_raws * raws)
{
for(size_t creatureIndex = 0; creatureIndex < raws->creatures.all.size(); creatureIndex++)
{
Expand Down
6 changes: 1 addition & 5 deletions ContentLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include "ItemConfiguration.h"
#include "common.h"

namespace df {
struct world_raws;
}

class ContentLoader
{
private:
Expand All @@ -38,7 +34,7 @@ class ContentLoader

bool translationComplete = false;

void gatherStyleIndices(df::world_raws * raws);
void gatherStyleIndices(df::world::T_raws * raws);
public:
ContentLoader(void);
~ContentLoader(void);
Expand Down
6 changes: 3 additions & 3 deletions Creatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ void ReadCreaturesToSegment( DFHack::Core& DF, WorldSegment* segment)
}

// skip if not weapon or worn item
if(itemslot->mode != df::unit_inventory_item::T_mode::Weapon &&
itemslot->mode != df::unit_inventory_item::T_mode::Worn &&
itemslot->mode != df::unit_inventory_item::T_mode::Piercing) {
if(itemslot->mode != df::inv_item_role_type::Weapon &&
itemslot->mode != df::inv_item_role_type::Worn &&
itemslot->mode != df::inv_item_role_type::Piercing) {
continue;
}

Expand Down
3 changes: 1 addition & 2 deletions DumpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ be intended for use by people not interested in development.
#include "df/itemdef_glovesst.h"
#include "df/itemdef_pantsst.h"
#include "df/world.h"
#include "df/world_raws.h"

//FIXME: filled with black magic
void dumpSegment()
Expand Down Expand Up @@ -153,7 +152,7 @@ void dumpSegment()

void DumpItemNamesToDisk(const char* filename)
{
df::world_raws::T_itemdefs &defs = df::global::world->raws.itemdefs;
auto &defs = df::global::world->raws.itemdefs;
FILE* fp = fopen(filename, "w");
if(!fp) {
return;
Expand Down
28 changes: 16 additions & 12 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,14 @@ namespace
{
draw_textf_border(font, uiColor(1), 2, (i++ * fontHeight), 0,
"tree name:%s type:%i", lookupTreeName(b->tree.index), b->tree.type);
uint16_t branches_dir = b->tree_tile.bits.branches_dir;
auto & tree_tile = b->tree_tile;
draw_textf_border(font, uiColor(1), 2, (i++ * fontHeight), 0,
"tree tile:%s%s%s%s%s%s%s",
b->tree_tile.bits.trunk ? " trunk" : "",
(branches_dir & 0x1) ? " >" : "",
(branches_dir & 0x2) ? " v" : "",
(branches_dir & 0x4) ? " <" : "",
(branches_dir & 0x8) ? " ^" : "",
tree_tile.bits.branch_w ? " >" : "",
tree_tile.bits.branch_n ? " v" : "",
tree_tile.bits.branch_e ? " <" : "",
tree_tile.bits.branch_s ? " ^" : "",
b->tree_tile.bits.branches ? " branches" : "",
b->tree_tile.bits.leaves ? " leaves" : ""
);
Expand Down Expand Up @@ -1173,15 +1173,16 @@ void saveMegashot(bool tall)
stonesenseState.map_segment.lockRead();

auto& ssState = stonesenseState.ssState;
// draw_textf_border(font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot...");
draw_textf_border(stonesenseState.font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot... Stonesense will become unresponsive after this process completes. Please close and re-open Stonesense.");
draw_textf_border(stonesenseState.font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot...");
al_flip_display();
std::filesystem::path filename = getAvailableFilename("screenshot");
// int timer = clock();
int timer = clock();
//back up all the relevant values
auto& ssConfig = stonesenseState.ssConfig;
GameConfiguration tempConfig = ssConfig;
GameState tempState = ssState;
uint32_t templiftX = stonesenseState.lift_segment_offscreen_x;
uint32_t templiftY = stonesenseState.lift_segment_offscreen_y;
int tempflags = al_get_new_bitmap_flags();

//now make them real big.
Expand Down Expand Up @@ -1326,19 +1327,22 @@ void saveMegashot(bool tall)


al_save_bitmap(filename.string().c_str(), bigFile);
// al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));
// timer = clock() - timer;
// PrintMessage("\tcreating screenshot took %ims\n", timer);
al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));
timer = clock() - timer;
PrintMessage("\tcreating screenshot took %.2fms\n", clockToMs(timer));
PrintMessage("\tlarge screenshot complete\n");
} else {
LogError("failed to take large screenshot; try zooming out\n");
}
// al_destroy_bitmap(bigFile);
al_destroy_bitmap(bigFile);
//restore everything that we changed.
stonesenseState.lift_segment_offscreen_x = templiftX;
stonesenseState.lift_segment_offscreen_y = templiftY;
ssConfig = tempConfig;
ssState = tempState;
al_set_new_bitmap_flags(tempflags);

al_flip_display();
stonesenseState.map_segment.unlockRead();
}

Expand Down
1 change: 1 addition & 0 deletions GameBuildings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "df/buildings_other_id.h"
#include "df/building_wellst.h"
#include "df/buildingitemst.h"
#include "df/item_constructed.h"
#include "df/item_slabst.h"
#include "df/itemimprovement.h"
Expand Down
2 changes: 1 addition & 1 deletion MaterialMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void MaterialMatcher<T>::set_material(T input, std::string token)
// Only scan inorganics if the token looks like it's actually pointing at one
if ((tokens[0] == "INORGANIC") || contains_wildcard(tokens[0]))
{
for (size_t i = 0; i < world->raws.inorganics.size(); i++)
for (size_t i = 0; i < world->raws.inorganics.all.size(); i++)
{
mat.decode(0, i);
check_match(input, token, mat.getToken(), 0, i);
Expand Down
6 changes: 6 additions & 0 deletions SpriteColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ ALLEGRO_COLOR uiColor(int32_t index)
case 3:
//lime
return ssConfig.config.colors.getDfColor(dfColors::lgreen, ssConfig.config.useDfColors);
case 4:
//light blue
return ssConfig.config.colors.getDfColor(dfColors::lblue, ssConfig.config.useDfColors);
case 5:
//light red
return ssConfig.config.colors.getDfColor(dfColors::lred, ssConfig.config.useDfColors);
default:
//white
return ssConfig.config.colors.getDfColor(dfColors::white, ssConfig.config.useDfColors);
Expand Down
12 changes: 10 additions & 2 deletions SpriteObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "df/material.h"
#include "df/unit.h"
#include "df/world.h"
#include "df/world_raws.h"

constexpr auto ALL_BORDERS = 255;

Expand Down Expand Up @@ -702,7 +701,7 @@ void c_sprite::set_by_xml(TiXmlElement *elemSprite)
} else if(!strcmp(equipsindexstr, "NONE")) {
itemsubtype = INVALID_INDEX;
} else {
df::world_raws::T_itemdefs &defs = df::global::world->raws.itemdefs;
auto &defs = df::global::world->raws.itemdefs;
switch(itemtype) {
using df::item_type;
case item_type::WEAPON:
Expand Down Expand Up @@ -1023,6 +1022,15 @@ void c_sprite::assemble_world_offset(int x, int y, int z, int plateoffset, Tile
}

ALLEGRO_COLOR shade_color = shadeAdventureMode(get_color(b), b->fog_of_war, b->designation.bits.outside);
if (ssConfig.show_designations && containsDesignations(b->designation, b->occ)) {
if (b->occ.bits.dig_auto) { shade_color = al_map_rgba(0, 255, 127, 127); }
if (b->occ.bits.dig_marked) {
shade_color = al_map_rgba(0, 127, 255, 127);
if (b->occ.bits.dig_auto) {
shade_color = partialBlend(shade_color, al_map_rgba(0, 255, 127, 127), 25);
}
}
}
if(chop && ( halftile == HALFPLATECHOP)) {
if(shade_color.a > 0.001f) {
b->AssembleSprite(
Expand Down
5 changes: 5 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,16 @@ void PrintMessage(const char* msg, ...) Wformat(printf,1,2);
void LogVerbose(const char* msg, ...) Wformat(printf,1,2);
void SetTitle(const char *format, ...) Wformat(printf,1,2);

float clockToMs(float clockTicks);

constexpr auto MAX_ANIMFRAME = 6;

// binary 00111111
constexpr auto ALL_FRAMES = 0b111111;

//from Gui.cpp
float clockToMs(float clockTicks);

//from UserInput.cpp
void doMouse();
void doKeys(int32_t key, uint32_t keymod);
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ Template for new versions:
## New Features

## Fixes
- `stonesense`: megashots no longer leave stonesense unresponsive

## Misc Improvements
- `stonesense`: different types of dig designations (normal, blueprint, autodig) now are distinctly tinted, similar to the vanilla DF interface

## Removed

Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL

ALLEGRO_EVENT event;
while (!al_get_thread_should_stop(main_thread)) {

if (redraw && al_event_queue_is_empty(queue)) {

al_rest(0);
Expand Down

0 comments on commit a7cf88b

Please sign in to comment.