diff --git a/Config.cpp b/Config.cpp index f19fbec1..77a4f67b 100644 --- a/Config.cpp +++ b/Config.cpp @@ -291,6 +291,10 @@ void parseConfigLine( string line ) string result = parseStrFromLine( "FONT", line ); ssConfig.font = al_create_path(result.c_str()); } + if (line.find("[USE_DF_COLORS") != -1){ + string result = parseStrFromLine("USE_DF_COLORS", line); + ssConfig.useDfColors = (result == "YES"); + } if( line.find("[BLACK_R") != -1) { int value = parseIntFromLine( "BLACK_R", line); if(value > 255) { diff --git a/Creatures.cpp b/Creatures.cpp index e4b8a39a..44ec8de9 100644 --- a/Creatures.cpp +++ b/Creatures.cpp @@ -45,11 +45,15 @@ int32_t charToUpper(int32_t c) ALLEGRO_USTR* bufferToUstr(const char* buffer, int length) { ALLEGRO_USTR* temp = al_ustr_new(""); - for(int i = 0; i < length; i++) { - switch((unsigned char)buffer[i]) { + for (int i = 0; i < length; i++) { + switch ((unsigned char)buffer[i]) { case 0: { - i = length; - break; + i = length; + break; + } + case 1: { + al_ustr_append_chr(temp, 0x263A); + break; } case 128: { al_ustr_append_chr(temp, 0xC7); @@ -222,7 +226,7 @@ void AssembleCreature(int drawx, int drawy, SS_Unit* creature, Tile * b) if(raw->caste[creature->caste]->caste_tile != 1) { spritenum = raw->caste[creature->caste]->caste_tile; } - ALLEGRO_COLOR tilecolor = ssConfig.colors.getDfColor(DFHack::Units::getCasteProfessionColor(creature->race,creature->caste,(df::profession)creature->profession)); + ALLEGRO_COLOR tilecolor = ssConfig.colors.getDfColor(DFHack::Units::getCasteProfessionColor(creature->race,creature->caste,(df::profession)creature->profession), ssConfig.useDfColors); int sheetx = spritenum % LETTERS_OBJECTSWIDE; int sheety = spritenum / LETTERS_OBJECTSWIDE; b->AssembleSprite( @@ -330,7 +334,7 @@ void DrawCreatureText(int drawx, int drawy, SS_Unit* creature ) if( ssConfig.show_creature_names ) { ALLEGRO_COLOR textcol; if(ssConfig.show_creature_professions == 2) { - textcol = ssConfig.colors.getDfColor(DFHack::Units::getProfessionColor(creature->origin)); + textcol = ssConfig.colors.getDfColor(DFHack::Units::getProfessionColor(creature->origin), ssConfig.useDfColors); //stupid hack to get legendary status of creatures if(creature->isLegend) { ALLEGRO_COLOR altcol; diff --git a/GUI.cpp b/GUI.cpp index 7dfc61b1..6bc4cd1b 100644 --- a/GUI.cpp +++ b/GUI.cpp @@ -17,6 +17,8 @@ using namespace std; #include "Tile.h" #include "UserInput.h" +#include "modules/Units.h" + #include "df/ui.h" #include "df/building_actual.h" @@ -42,6 +44,8 @@ using namespace std; #include "df/tissue_style_raw.h" #include "df/viewscreen_dungeonmodest.h" +#include "df/viewscreen_dungeon_wrestlest.h" +#include "df/ui_advmode.h" #include "df/report.h" extern ALLEGRO_FONT *font; @@ -313,7 +317,7 @@ void draw_ustr_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, fl void draw_report_border(const ALLEGRO_FONT *font, float x, float y, int flags, const df::report * report) { - ALLEGRO_COLOR color = ssConfig.colors.getDfColor(report->color); + ALLEGRO_COLOR color = ssConfig.colors.getDfColor(report->color, ssConfig.useDfColors); draw_text_border(font, color, x, y, flags, report->text.c_str()); } @@ -466,6 +470,37 @@ void drawDebugCursor(WorldSegment * segment) 0); } +void drawAdvmodeMenuTalk(const ALLEGRO_FONT *font, int x, int y) +{ + df::ui_advmode * menu = df::global::ui_advmode; + if (!menu) + return; + if (menu->talk_targets.size() == 0) + return; + int line = menu->talk_targets.size() + 3; + draw_textf_border(font, ssConfig.colors.getDfColor(dfColors::white, ssConfig.useDfColors), x, (y - (line*al_get_font_line_height(font))), 0, + "Who will you talk to?"); + line -= 2; + for (int i = 0; i < menu->talk_targets.size(); i++) + { + ALLEGRO_COLOR color = ssConfig.colors.getDfColor(dfColors::lgray, ssConfig.useDfColors); + if (i == menu->talk_target_selection) + color = ssConfig.colors.getDfColor(dfColors::white, ssConfig.useDfColors); + df::unit * crete = Units::GetCreature(Units::FindIndexById(menu->talk_targets[i]->unit_id)); + if (crete) + { + ALLEGRO_USTR * string = al_ustr_newf("%s, ", Units::getProfessionName(crete).c_str()); + int8_t gender = df::global::world->raws.creatures.all[crete->race]->caste[crete->caste]->gender; + if (gender == 0) + al_ustr_append_chr(string, 0x2640); + else if (gender == 1) + al_ustr_append_chr(string, 0x2642); + draw_ustr_border(font, color, x + 5, (y - ((line - i)*al_get_font_line_height(font))), 0, + string); + } + } +} + void drawDebugInfo(WorldSegment * segment) { using df::global::ui; @@ -480,18 +515,14 @@ void drawDebugInfo(WorldSegment * segment) draw_textf_border(font, uiColor(1), 2, (i++*al_get_font_line_height(font)), 0, "Tile 0x%x (%i,%i,%i)", b, b->x, b->y, b->z); } df::viewscreen * vs = Gui::getCurViewscreen(); - auto advScreen = strict_virtual_cast(vs); - if (advScreen) + if (auto advScreen = strict_virtual_cast(vs)) { - draw_textf_border(font, uiColor(1), 2, (i++*al_get_font_line_height(font)), 0, - "Adventure viewscreen: [%d,%d,%d], announce_y=%d, announce_idx=%d, announce_more=%d", - advScreen->x, advScreen->y, advScreen->z, advScreen->announce_y, advScreen->announce_idx, advScreen->announce_more); - if (advScreen->announce_idx >= 0) + if (df::global::ui_advmode) { - draw_report_border(font, 2, (i++*al_get_font_line_height(font)), 0, - df::global::world->status.announcements[advScreen->announce_idx]); + draw_textf_border(font, uiColor(1), 2, (i++*al_get_font_line_height(font)), 0, + "Current menu: %s", + df::enum_traits::key_table[df::global::ui_advmode->menu]); } - } draw_textf_border(font, uiColor(1), 2, (i++*al_get_font_line_height(font)), 0, "Coord:(%i,%i,%i)", segment->segState.dfCursor.x, segment->segState.dfCursor.y, segment->segState.dfCursor.z); @@ -1078,6 +1109,7 @@ void paintboard() drawDebugCursor(segment); draw_announcements(font, ssState.ScreenW / 2, ssState.ScreenH - 20, ALLEGRO_ALIGN_CENTRE, df::global::world->status.announcements); + drawAdvmodeMenuTalk(font, 5, ssState.ScreenH - 5); if(ssConfig.debug_mode) { draw_textf_border(font, uiColor(1), 10, 3*al_get_font_line_height(font), 0, "Map Read Time: %.2fms", ssTimers.read_time); diff --git a/Overlay.cpp b/Overlay.cpp index dbf78c94..e336102d 100644 --- a/Overlay.cpp +++ b/Overlay.cpp @@ -7,6 +7,7 @@ #include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_dungeonmodest.h" +#include "df/ui_advmode.h" DFhackCExport void * SDL_GetVideoSurface(void); @@ -37,17 +38,30 @@ void Overlay::ReadTileLocations() } ssState.ScreenW = fontx*width; - ssState.ScreenH = fonty*height; + ssState.ScreenH = fonty*height; } void Overlay::CheckViewscreen() { df::viewscreen * vs = Gui::getCurViewscreen(); virtual_identity * id = virtual_identity::get(vs); - if(id == &df::viewscreen_dwarfmodest::_identity - || id == &df::viewscreen_dungeonmodest::_identity){ + if (id == &df::viewscreen_dwarfmodest::_identity) + { + good_viewscreen = true; + } + else if (id == &df::viewscreen_dungeonmodest::_identity) + { + if (!df::global::ui_advmode) good_viewscreen = true; - } else { + else if (df::global::ui_advmode->menu == df::ui_advmode_menu::Default) + good_viewscreen = true; + else if (df::global::ui_advmode->menu == df::ui_advmode_menu::Talk) + good_viewscreen = true; + else + good_viewscreen = false; + } + else + { good_viewscreen = false; } } diff --git a/SpriteColors.cpp b/SpriteColors.cpp index e2a05355..df076830 100644 --- a/SpriteColors.cpp +++ b/SpriteColors.cpp @@ -254,28 +254,28 @@ ALLEGRO_COLOR blinkTechnicolor() switch(currentAnimationFrame & 0x07){ case 0x00: //yellow; - return ssConfig.colors.getDfColor(dfColors::yellow); + return ssConfig.colors.getDfColor(dfColors::yellow, ssConfig.useDfColors); case 0x01: //blue - return ssConfig.colors.getDfColor(dfColors::blue); + return ssConfig.colors.getDfColor(dfColors::blue, ssConfig.useDfColors); case 0x02: //red - return ssConfig.colors.getDfColor(dfColors::red); + return ssConfig.colors.getDfColor(dfColors::red, ssConfig.useDfColors); case 0x03: //magenta - return ssConfig.colors.getDfColor(dfColors::magenta); + return ssConfig.colors.getDfColor(dfColors::magenta, ssConfig.useDfColors); case 0x04: //lred - return ssConfig.colors.getDfColor(dfColors::lred); + return ssConfig.colors.getDfColor(dfColors::lred, ssConfig.useDfColors); case 0x05: //green - return ssConfig.colors.getDfColor(dfColors::green); + return ssConfig.colors.getDfColor(dfColors::green, ssConfig.useDfColors); case 0x06: //brown - return ssConfig.colors.getDfColor(dfColors::brown); + return ssConfig.colors.getDfColor(dfColors::brown, ssConfig.useDfColors); default: //lime - return ssConfig.colors.getDfColor(dfColors::lgreen); + return ssConfig.colors.getDfColor(dfColors::lgreen, ssConfig.useDfColors); } } @@ -286,18 +286,18 @@ ALLEGRO_COLOR uiColor(int32_t index) { case 0: //black; - return ssConfig.colors.getDfColor(dfColors::black); + return ssConfig.colors.getDfColor(dfColors::black, ssConfig.useDfColors); case 1: //white - return ssConfig.colors.getDfColor(dfColors::white); + return ssConfig.colors.getDfColor(dfColors::white, ssConfig.useDfColors); case 2: //yellow; - return ssConfig.colors.getDfColor(dfColors::yellow); + return ssConfig.colors.getDfColor(dfColors::yellow, ssConfig.useDfColors); case 3: //lime - return ssConfig.colors.getDfColor(dfColors::lgreen); + return ssConfig.colors.getDfColor(dfColors::lgreen, ssConfig.useDfColors); default: //white - return ssConfig.colors.getDfColor(dfColors::white); + return ssConfig.colors.getDfColor(dfColors::white, ssConfig.useDfColors); } } \ No newline at end of file diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index 6366c360..309fa6ed 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -1260,17 +1260,17 @@ ALLEGRO_COLOR c_sprite::get_color(void* tile) case ShadeVein: return lookupMaterialColor(b->veinMaterial); case ShadeMatFore: - return ssConfig.colors.getDfColor(lookupMaterialFore(b->material.type, b->material.index), lookupMaterialBright(b->material.type, b->material.index)); + return ssConfig.colors.getDfColor(lookupMaterialFore(b->material.type, b->material.index), lookupMaterialBright(b->material.type, b->material.index), ssConfig.useDfColors); case ShadeMatBack: - return ssConfig.colors.getDfColor(lookupMaterialBack(b->material.type, b->material.index)); + return ssConfig.colors.getDfColor(lookupMaterialBack(b->material.type, b->material.index), ssConfig.useDfColors); case ShadeLayerFore: - return ssConfig.colors.getDfColor(lookupMaterialFore(b->layerMaterial.type, b->layerMaterial.index), lookupMaterialBright(b->layerMaterial.type, b->layerMaterial.index)); + return ssConfig.colors.getDfColor(lookupMaterialFore(b->layerMaterial.type, b->layerMaterial.index), lookupMaterialBright(b->layerMaterial.type, b->layerMaterial.index), ssConfig.useDfColors); case ShadeLayerBack: - return ssConfig.colors.getDfColor(lookupMaterialBack(b->layerMaterial.type, b->layerMaterial.index)); + return ssConfig.colors.getDfColor(lookupMaterialBack(b->layerMaterial.type, b->layerMaterial.index), ssConfig.useDfColors); case ShadeVeinFore: - return ssConfig.colors.getDfColor(lookupMaterialFore(b->veinMaterial.type, b->veinMaterial.index), lookupMaterialBright(b->veinMaterial.type, b->veinMaterial.index)); + return ssConfig.colors.getDfColor(lookupMaterialFore(b->veinMaterial.type, b->veinMaterial.index), lookupMaterialBright(b->veinMaterial.type, b->veinMaterial.index), ssConfig.useDfColors); case ShadeVeinBack: - return ssConfig.colors.getDfColor(lookupMaterialBack(b->veinMaterial.type, b->veinMaterial.index)); + return ssConfig.colors.getDfColor(lookupMaterialBack(b->veinMaterial.type, b->veinMaterial.index), ssConfig.useDfColors); case ShadeBodyPart: if(b->occ.bits.unit && b->creature) { dayofLife = b->creature->birth_year*12*28 + b->creature->birth_time/1200; @@ -1333,7 +1333,7 @@ ALLEGRO_COLOR c_sprite::get_color(void* tile) } case ShadeJob: if(b->occ.bits.unit && b->creature) { - return ssConfig.colors.getDfColor(Units::getProfessionColor(b->creature->origin)); + return ssConfig.colors.getDfColor(Units::getProfessionColor(b->creature->origin), ssConfig.useDfColors); } else { return al_map_rgb(255,255,255); } diff --git a/commonTypes.h b/commonTypes.h index 06fd9704..40a33713 100644 --- a/commonTypes.h +++ b/commonTypes.h @@ -2,6 +2,8 @@ #include "common.h" #include "SpriteColors.h" +#include "df/enabler.h" + enum ShadeBy { ShadeNone, @@ -119,14 +121,18 @@ class dfColors color & operator [] (color_name col) { return colors[col]; } - ALLEGRO_COLOR getDfColor(int color) { + ALLEGRO_COLOR getDfColor(int color, bool useDfColors) { if(color < 0 || color >= 16) { return al_map_rgb(255,255,255); } + if (useDfColors) + { + return al_map_rgb_f(df::global::enabler->ccolor[color][0], df::global::enabler->ccolor[color][1], df::global::enabler->ccolor[color][2]); + } return colors[ (color_name) color].al; } - ALLEGRO_COLOR getDfColor(int color, int bright) { - return getDfColor(color+(bright*8)); + ALLEGRO_COLOR getDfColor(int color, int bright, bool useDfColors) { + return getDfColor(color + (bright * 8), useDfColors); } }; @@ -184,6 +190,7 @@ struct GameConfiguration { bool saveImageCache; bool cache_images; int imageCacheSize; + bool useDfColors; dfColors colors; bool opengl; bool directX; diff --git a/main.cpp b/main.cpp index 3636d208..de7aed10 100644 --- a/main.cpp +++ b/main.cpp @@ -431,6 +431,7 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms) contentLoader = new ContentLoader(); ssConfig.zoom = 0; ssConfig.scale = 1.0f; + ssConfig.useDfColors = false; ssTimers.assembly_time = 1.0f; ssTimers.beautify_time = 1.0f; ssTimers.overlay_time = 1.0f; diff --git a/resources/init.txt b/resources/init.txt index 896420d0..a817ead5 100644 --- a/resources/init.txt +++ b/resources/init.txt @@ -84,7 +84,7 @@ Sets weather Stonesense should shade in the fog-of-war partially hidden tiles. --Debug Mode-- Sets Stonesense in debug mode. Adds additional information to displays. -[DEBUGMODE:NO] +[DEBUGMODE:YES] Set's the debug cursor to follow the cursor from DF when it is there. [FOLLOW_DF_CURSOR:YES] @@ -134,6 +134,9 @@ compatibility, but is very slow. Stonesense can use the colors from DF for various purposes. these are set here the same way as in DF +However, if this is set to yes, these aren't used. +[USE_DF_COLORS:YES] + [BLACK_R:0] [BLACK_G:0] [BLACK_B:0]