Skip to content

Commit

Permalink
Added the talk menu to adventure mode, and made stonesense use the DF…
Browse files Browse the repository at this point in the history
… colors by default.
  • Loading branch information
RosaryMala committed Jul 2, 2014
1 parent 701592b commit 0d19548
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 44 deletions.
4 changes: 4 additions & 0 deletions Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 10 additions & 6 deletions Creatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
52 changes: 42 additions & 10 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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;

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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;
Expand All @@ -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<df::viewscreen_dungeonmodest>(vs);
if (advScreen)
if (auto advScreen = strict_virtual_cast<df::viewscreen_dungeonmodest>(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<df::ui_advmode_menu>::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);
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 18 additions & 4 deletions Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "df/viewscreen_dwarfmodest.h"
#include "df/viewscreen_dungeonmodest.h"
#include "df/ui_advmode.h"


DFhackCExport void * SDL_GetVideoSurface(void);
Expand Down Expand Up @@ -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;
}
}
Expand Down
26 changes: 13 additions & 13 deletions SpriteColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}
14 changes: 7 additions & 7 deletions SpriteObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 10 additions & 3 deletions commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "common.h"
#include "SpriteColors.h"
#include "df/enabler.h"


enum ShadeBy {
ShadeNone,
Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -184,6 +190,7 @@ struct GameConfiguration {
bool saveImageCache;
bool cache_images;
int imageCacheSize;
bool useDfColors;
dfColors colors;
bool opengl;
bool directX;
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion resources/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 0d19548

Please sign in to comment.