Skip to content

Commit 26ea8b8

Browse files
committed
feat(zq): allow customizing invalid checkerboard color
1 parent 2594196 commit 26ea8b8

File tree

8 files changed

+50
-48
lines changed

8 files changed

+50
-48
lines changed

src/dialog/object_pages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ void ObjectTemplate::draw_null(BITMAP* dest, int x, int y, int w, int h, bool al
742742
case 2:
743743
{
744744
auto sz = std::max(w,h);
745-
draw_checkerboard(dest, x, y, 0, 0, sz, sz/(alt?2:1));
745+
draw_checkerboard(dest, x, y, sz);
746746
break;
747747
}
748748
case 1:

src/dialog/options.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ void call_options_dlg()
1515
OptionsDialog().show();
1616
}
1717

18-
extern int32_t EnableTooltips, GridColor, CmbCursorCol, TilePgCursorCol, TTipHLCol,
18+
extern int EnableTooltips, GridColor, CmbCursorCol, TilePgCursorCol, TTipHLCol,
19+
CheckerCol1, CheckerCol2,
1920
CmbPgCursorCol, KeyboardRepeatDelay, TooltipsHighlight, KeyboardRepeatRate,
2021
pixeldb, infobg, MMapCursorStyle, LayerDitherBG, LayerDitherSz;
2122
extern bool allowHideMouse;
@@ -59,6 +60,8 @@ void OptionsDialog::loadOptions()
5960
opts[OPT_TPG_CURS_COL] = TilePgCursorCol;
6061
opts[OPT_CPG_CURS_COL] = CmbPgCursorCol;
6162
opts[OPT_TTIP_HL_COL] = TTipHLCol;
63+
opts[OPT_TTIP_CHECKER1_COL] = CheckerCol1;
64+
opts[OPT_TTIP_CHECKER2_COL] = CheckerCol2;
6265
opts[OPT_SNAPFORMAT] = SnapshotFormat;
6366
opts[OPT_SNAPSCALE] = SnapshotScale;
6467
opts[OPT_KBREPDEL] = KeyboardRepeatDelay;
@@ -179,6 +182,14 @@ void OptionsDialog::saveOption(int ind)
179182
TTipHLCol = v;
180183
zc_set_config("zquest", "ttip_hl_color", v);
181184
break;
185+
case OPT_TTIP_CHECKER1_COL:
186+
CheckerCol1 = v;
187+
zc_set_config("zquest", "checker_color_1", v);
188+
break;
189+
case OPT_TTIP_CHECKER2_COL:
190+
CheckerCol2 = v;
191+
zc_set_config("zquest", "checker_color_2", v);
192+
break;
182193
case OPT_SNAPFORMAT:
183194
SnapshotFormat = v;
184195
zc_set_config("zquest", "snapshot_format", v);
@@ -960,22 +971,22 @@ std::shared_ptr<GUI::Widget> OptionsDialog::view()
960971
ROW_DDOWN(OPT_ASINTERVAL, "Auto-save Interval:", asIntervalList),
961972
ROW_DDOWN(OPT_ASRETENTION, "Auto-save Retention:", asRetentionList),
962973
ROW_CHECK(OPT_UNCOMP_AUTOSAVE, "Uncompressed Auto Saves"),
974+
ROW_DDOWN_I(OPT_MAPCURSOR, "Minimap Cursor:", mmapCursList,
975+
"The color of the current screen outline on the minimap."
976+
" Either solid or blinking between two colors."),
963977
ROW_DDOWN(OPT_GRIDCOL, "Grid Color:", colorList),
964978
ROW_DDOWN(OPT_CMB_CURS_COL, "Combo Column SelColor:", colorList),
965979
ROW_DDOWN(OPT_TPG_CURS_COL, "Tile Page SelColor:", colorList),
966980
ROW_DDOWN(OPT_CPG_CURS_COL, "Combo Page SelColor:", colorList),
967981
ROW_DDOWN(OPT_TTIP_HL_COL, "Tooltip Highlight SelColor:", colorList),
968-
ROW_DDOWN_I(OPT_MAPCURSOR, "Minimap Cursor:", mmapCursList,
969-
"The color of the current screen outline on the minimap."
970-
" Either solid or blinking between two colors."),
982+
ROW_DDOWN(OPT_TTIP_CHECKER1_COL, "Checker Color 1:", colorList),
983+
ROW_DDOWN(OPT_TTIP_CHECKER2_COL, "Checker Color 2:", colorList),
984+
ROW_DDOWN_I(OPT_INVALID_BG, "Invalid Data BG:", invalidDataBGList,
985+
"The background used for invalid data in the tile pages, favorite combos, map, and ajacent screens"),
971986
ROW_DDOWN_I(OPT_LYR_DITH_BG, "Layer Dither BG:", bgColorList,
972987
"The color used for the background when dithering the bottom layer."),
973988
ROW_DDOWN_I(OPT_LYR_DITH_SZ, "Layer Dither Size:", ditherSzList,
974-
"The size of the dither pattern used for non-highlighted screens."),
975-
ROW_DDOWN_I(OPT_INVALID_BG, "Invalid Data BG:", invalidDataBGList,
976-
"The background used for invalid data in the tile pages, favorite combos, map, and ajacent screens"),
977-
ROW_DDOWN(OPT_SNAPFORMAT, "Snapshot Format:", snapFormatList),
978-
ROW_DDOWN(OPT_SNAPSCALE, "Snapshot Scale:", snapshotScaleList)
989+
"The size of the dither pattern used for non-highlighted screens.")
979990
),
980991
Rows<3>(vAlign = 0.0,
981992
ROW_TF_RANGE(OPT_KBREPDEL, "Keyboard Repeat Delay:", 0, 99999),
@@ -986,7 +997,9 @@ std::shared_ptr<GUI::Widget> OptionsDialog::view()
986997
ROW_DDOWN(OPT_COMPILE_DONE, "Compile SFX (Slots):", sfx_list),
987998
ROW_TF_RANGE(OPT_COMPILE_VOL, "Compile SFX Volume %:", 0, 500),
988999
ROW_DDOWN(OPT_BOTTOM8, "Bottom 8 pixels:", bottom8_list),
989-
ROW_TF_RANGE(OPT_TOOLTIP_TIMER, "Tooltip Timer:", 0, 60*60)
1000+
ROW_TF_RANGE(OPT_TOOLTIP_TIMER, "Tooltip Timer:", 0, 60*60),
1001+
ROW_DDOWN(OPT_SNAPFORMAT, "Snapshot Format:", snapFormatList),
1002+
ROW_DDOWN(OPT_SNAPSCALE, "Snapshot Scale:", snapshotScaleList)
9901003
)
9911004
))
9921005
)

src/dialog/options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class OptionsDialog: public GUI::Dialog<OptionsDialog>
3030
//
3131
OPT_ABRETENTION, OPT_ASINTERVAL, OPT_ASRETENTION, OPT_UNCOMP_AUTOSAVE, OPT_GRIDCOL,
3232
OPT_SNAPFORMAT, OPT_SNAPSCALE, OPT_KBREPDEL, OPT_KBREPRATE, OPT_CMB_CURS_COL,
33-
OPT_TPG_CURS_COL, OPT_CPG_CURS_COL, OPT_TTIP_HL_COL,
33+
OPT_TPG_CURS_COL, OPT_CPG_CURS_COL, OPT_TTIP_HL_COL, OPT_TTIP_CHECKER1_COL,
34+
OPT_TTIP_CHECKER2_COL,
3435
//
3536
OPT_LYR_DITH_BG, OPT_LYR_DITH_SZ,
3637
//

src/gui/jwin.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ using std::istringstream;
2121
void update_hw_screen(bool force);
2222
extern int32_t zq_screen_w, zq_screen_h;
2323
extern int32_t joystick_index;
24+
int CheckerCol1 = 7, CheckerCol2 = 8;
2425

2526
extern bool is_editor();
2627

@@ -9883,15 +9884,12 @@ void draw_x(BITMAP* dest, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_
98839884
line(dest, x1, y2, x2, y1, color);
98849885
}
98859886

9886-
void draw_checkerboard(BITMAP* dest, int x, int y, int offx, int offy, int sz, optional<int> cb_sz)
9887+
void draw_checkerboard(BITMAP* dest, int x, int y, int sz, optional<int> cb_sz, int offx, int offy)
98879888
{
98889889
if(!cb_sz)
9889-
cb_sz = sz;
9890-
bool inv = XOR(((x + offx) % (*cb_sz * 2) >= *cb_sz), ((y + offy) % (*cb_sz * 2) >= *cb_sz));
9891-
int ox = -x, oy = -y;
9892-
if(inv)
9893-
ox += *cb_sz;
9894-
ditherrectfill(dest, x, y, x+sz-1, y+sz-1, vc(7), dithChecker, *cb_sz, ox, oy, vc(8));
9890+
cb_sz = sz/2;
9891+
int ox = -x+offx, oy = -y+offy;
9892+
ditherrectfill(dest, x, y, x+sz-1, y+sz-1, vc(CheckerCol1), dithChecker, *cb_sz, ox, oy, vc(CheckerCol2));
98959893
}
98969894

98979895
int32_t d_vsync_proc(int32_t msg,DIALOG *d,int32_t c)

src/gui/jwin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ int32_t d_jwinbutton_proc(int32_t msg, DIALOG *d, int32_t c);
288288

289289
//Misc bitmap drawing
290290
void draw_x(BITMAP* dest, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color);
291-
void draw_checkerboard(BITMAP* dest, int basex, int basey, int x, int y, int sz, optional<int> cb_sz = nullopt);
291+
void draw_checkerboard(BITMAP* dest, int basex, int basey, int sz, optional<int> cb_sz = nullopt, int x = 0, int y = 0);
292292

293293
int32_t d_vsync_proc(int32_t msg,DIALOG *,int32_t c);
294294

src/zq/zq_class.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,7 +3801,7 @@ void zmap::drawstaticblock(BITMAP* dest,int32_t x,int32_t y)
38013801
{
38023802
if (InvalidBG == 2)
38033803
{
3804-
draw_checkerboard(dest, x, y, 8, 8, 16);
3804+
draw_checkerboard(dest, x, y, 16);
38053805
}
38063806
else if(InvalidBG == 1)
38073807
{
@@ -3827,7 +3827,7 @@ void zmap::drawstaticcolumn(BITMAP* dest,int32_t x,int32_t y)
38273827
if (InvalidBG == 2)
38283828
{
38293829
for(int32_t q = 0; q < 11; ++q)
3830-
draw_checkerboard(dest, x, y + q * 16, 8, 8, 16);
3830+
draw_checkerboard(dest, x, y + q * 16, 16);
38313831
}
38323832
else if(InvalidBG == 1)
38333833
{
@@ -3853,7 +3853,7 @@ void zmap::drawstaticrow(BITMAP* dest,int32_t x,int32_t y)
38533853
if (InvalidBG == 2)
38543854
{
38553855
for (int32_t q = 0; q < 16; ++q)
3856-
draw_checkerboard(dest, x + q * 16, y, 8, 8, 16);
3856+
draw_checkerboard(dest, x + q * 16, y, 16);
38573857
}
38583858
else if(InvalidBG == 1)
38593859
{

src/zq/zq_tiles.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5513,7 +5513,7 @@ void draw_tiles(BITMAP* dest,int32_t first,int32_t cs, int32_t f, bool large, bo
55135513
{
55145514
if (InvalidBG == 2)
55155515
{
5516-
draw_checkerboard(dest, x, y, 0, 0, w);
5516+
draw_checkerboard(dest, x, y, w);
55175517
}
55185518
else if(InvalidBG == 1)
55195519
{
@@ -5589,7 +5589,7 @@ void tile_info_0(int32_t tile,int32_t tile2,int32_t cs,int32_t copy,int32_t copy
55895589
{
55905590
if (InvalidBG == 2)
55915591
{
5592-
draw_checkerboard(screen2, 34 * mul, 216 * mul + yofs, 0, 0, 16 * mul, 8 * mul);
5592+
draw_checkerboard(screen2, 34 * mul, 216 * mul + yofs, 16 * mul);
55935593
}
55945594
else if(InvalidBG == 1)
55955595
{
@@ -5690,7 +5690,7 @@ void tile_info_1(int32_t oldtile,int32_t oldflip,int32_t oldcs,int32_t tile,int3
56905690
{
56915691
if (InvalidBG == 2)
56925692
{
5693-
draw_checkerboard(screen2, 124 * mul, 216 * mul + yofs, 0, 0, 16 * mul, 8 * mul);
5693+
draw_checkerboard(screen2, 124 * mul, 216 * mul + yofs, 16 * mul);
56945694
}
56955695
else if(InvalidBG == 1)
56965696
{
@@ -16661,7 +16661,7 @@ void combo_info(int32_t tile,int32_t tile2,int32_t cs,int32_t copy,int32_t copyc
1666116661
{
1666216662
if (InvalidBG == 2)
1666316663
{
16664-
draw_checkerboard(screen2, 31 * mul, 216 * mul + yofs, 0, 0, 16 * mul, 8 * mul);
16664+
draw_checkerboard(screen2, 31 * mul, 216 * mul + yofs, 16 * mul);
1666516665
}
1666616666
else if(InvalidBG == 1)
1666716667
{
@@ -16717,7 +16717,7 @@ void combo_info(int32_t tile,int32_t tile2,int32_t cs,int32_t copy,int32_t copyc
1671716717
{
1671816718
if (InvalidBG == 2)
1671916719
{
16720-
draw_checkerboard(screen2, 136 * mul, 216 * mul + yofs, 0, 0, 16 * mul, 8 * mul);
16720+
draw_checkerboard(screen2, 136 * mul, 216 * mul + yofs, 16 * mul);
1672116721
}
1672216722
else if(InvalidBG == 1)
1672316723
{

src/zq/zquest.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,11 @@ static int32_t do_NewQuest()
562562
return onNew();
563563
}
564564

565+
extern int CheckerCol1, CheckerCol2;
565566
int32_t alignment_arrow_timer=0;
566567
int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
567568
int32_t Flags=0,Flag=0,menutype=(m_block);
568-
int32_t MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, GridColor = 15,
569+
int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, GridColor = 15,
569570
CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
570571
TileProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
571572
LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
@@ -1545,7 +1546,7 @@ static MENU etc_menu[] =
15451546
static MENU zscript_menu[] =
15461547
{
15471548
{ (char *)"Compile &ZScript...", onCompileScript, NULL, 0, NULL },
1548-
{ (char *)"&View Slots...", onSlotPreview, NULL, 0, NULL },
1549+
{ (char *)"&Assign Slots...", onSlotAssign, NULL, D_DISABLED, NULL },
15491550
//divider
15501551
{ (char *)"", NULL, NULL, 0, NULL },
15511552
{ (char *)"&Compiler Settings", onZScriptCompilerSettings, NULL, 0, NULL },
@@ -5350,7 +5351,7 @@ void draw_screenunit(int32_t unit, int32_t flags)
53505351
{
53515352
if (InvalidBG == 2)
53525353
{
5353-
draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w / 2, sqr.w / 2, sqr.w);
5354+
draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
53545355
}
53555356
else if (InvalidBG == 1)
53565357
{
@@ -6353,7 +6354,7 @@ void draw_screenunit(int32_t unit, int32_t flags)
63536354
{
63546355
if (InvalidBG == 2)
63556356
{
6356-
draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 16, 16, 32);
6357+
draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 32);
63576358
}
63586359
else if(InvalidBG == 1)
63596360
{
@@ -6428,7 +6429,7 @@ void draw_screenunit(int32_t unit, int32_t flags)
64286429
{
64296430
if (InvalidBG == 2)
64306431
{
6431-
draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w / 2, sqr.w / 2, sqr.w);
6432+
draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
64326433
}
64336434
else if(InvalidBG == 1)
64346435
{
@@ -9987,7 +9988,6 @@ bool has_command_info(int cmd)
99879988
case cmdDrawingModePool:
99889989
case cmdQRSearch:
99899990
case cmdDrawingModeAutocombo:
9990-
case cmdViewScriptSlots:
99919991
return true;
99929992
}
99939993
return false;
@@ -10468,9 +10468,6 @@ std::string get_command_infostr(int cmd)
1046810468
case cmdDrawingModeAutocombo:
1046910469
infostr = "Switches to Autcombo drawing mode";
1047010470
break;
10471-
case cmdViewScriptSlots:
10472-
infostr = "Shows a list of all script slots";
10473-
break;
1047410471
}
1047510472
return infostr;
1047610473
}
@@ -10623,7 +10620,8 @@ void domouse()
1062310620
{
1062410621
static int mouse_down = 0;
1062510622
static int32_t scrolldelay = 0;
10626-
auto [x, y] = zc_get_mouse();
10623+
int32_t x=gui_mouse_x();
10624+
int32_t y=gui_mouse_y();
1062710625
double startx=mapscreen_x+(showedges?(16*mapscreensize):0);
1062810626
double starty=mapscreen_y+(showedges?(16*mapscreensize):0);
1062910627
int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreensize):0);
@@ -23091,7 +23089,6 @@ void clearAssignSlotDlg()
2309123089
assignscript_dlg[13].flags = 0;
2309223090
}
2309323091

23094-
//Deprecated for now, we'll be back later I swear!
2309523092
int32_t onSlotAssign()
2309623093
{
2309723094
clearAssignSlotDlg();
@@ -23132,14 +23129,6 @@ int32_t onSlotAssign()
2313223129
return D_O_K;
2313323130
}
2313423131

23135-
void call_view_script_slots();
23136-
23137-
int32_t onSlotPreview()
23138-
{
23139-
call_view_script_slots();
23140-
return D_O_K;
23141-
}
23142-
2314323132
void inc_script_name(string& name)
2314423133
{
2314523134
size_t pos = name.find_last_not_of("0123456789");
@@ -27914,6 +27903,8 @@ int32_t main(int32_t argc,char **argv)
2791427903
TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
2791527904
CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
2791627905
TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
27906+
CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
27907+
CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
2791727908
SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
2791827909
SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
2791927910
SavePaths = zc_get_config("zquest","save_paths",1);
@@ -30429,7 +30420,6 @@ command_pair commands[cmdMAX]=
3042930420
{ "Rule Templates", 0, (intF) PickRuleTemplate },
3043030421
{ "Smart Compile ZScript", 0, (intF) onSmartCompile },
3043130422
{ "Autocombo Mode", 0, (intF) onDrawingModeAuto },
30432-
{ "View Script Slots", 0, (intF) onSlotPreview },
3043330423
};
3043430424

3043530425
/********************************/

0 commit comments

Comments
 (0)