Skip to content

Commit

Permalink
Merge branch 'main' into improve_brush_icon_box
Browse files Browse the repository at this point in the history
  • Loading branch information
majestyotbr authored Jun 10, 2024
2 parents 81051bd + 1e9f698 commit 12a736d
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 44 deletions.
5 changes: 4 additions & 1 deletion data/menubar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@
<item name="Ghost $loose items" hotkey="G" action="GHOST_ITEMS" help="Ghost items (except ground)."/>
<item name="Ghost $higher floors" hotkey="Ctrl+L" action="GHOST_HIGHER_FLOORS" help="Ghost floors."/>
<item name="Show $client box" hotkey="Shift+I" action="SHOW_INGAME_BOX" help="Shadows out areas not visible ingame (from the center of the screen)."/>
<item name="Show $lights" hotkey="Shift+L" action="SHOW_LIGHTS" help="Show lights."/>
<menu name="$Lights">
<item name="Show $lights" hotkey="Shift+L" action="SHOW_LIGHTS" help="Show lights."/>
<item name="Show $light strength" hotkey="Shift+K" action="SHOW_LIGHT_STRENGTH" help="Show indicators of light strength."/>
</menu>
<item name="Show $Grid" hotkey="Shift+G" action="SHOW_GRID" help="Shows a grid over all items."/>
<item name="H$ighlight items" hotkey="V" action="HIGHLIGHT_ITEMS" help="Highlight tiles with items on them."/>
<separator/>
Expand Down
56 changes: 30 additions & 26 deletions source/main_menubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ MainMenuBar::MainMenuBar(MainFrame* frame) :
MAKE_ACTION(SHOW_EXTRA, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_INGAME_BOX, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_LIGHTS, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_LIGHT_STRENGTH, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_GRID, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_MONSTERS, wxITEM_CHECK, OnChangeViewSettings);
MAKE_ACTION(SHOW_SPAWNS_MONSTER, wxITEM_CHECK, OnChangeViewSettings);
Expand Down Expand Up @@ -468,6 +469,7 @@ void MainMenuBar::LoadValues() {
CheckItem(SHOW_SHADE, g_settings.getBoolean(Config::SHOW_SHADE));
CheckItem(SHOW_INGAME_BOX, g_settings.getBoolean(Config::SHOW_INGAME_BOX));
CheckItem(SHOW_LIGHTS, g_settings.getBoolean(Config::SHOW_LIGHTS));
CheckItem(SHOW_LIGHT_STRENGTH, g_settings.getBoolean(Config::SHOW_LIGHT_STRENGTH));
CheckItem(SHOW_ALL_FLOORS, g_settings.getBoolean(Config::SHOW_ALL_FLOORS));
CheckItem(GHOST_ITEMS, g_settings.getBoolean(Config::TRANSPARENT_ITEMS));
CheckItem(GHOST_HIGHER_FLOORS, g_settings.getBoolean(Config::TRANSPARENT_FLOORS));
Expand Down Expand Up @@ -576,7 +578,7 @@ bool MainMenuBar::Load(const FileName &path, wxArrayString &warnings, wxString &
}

#ifdef __LINUX__
const int count = 46;
const int count = 47;
wxAcceleratorEntry entries[count];
// Edit
entries[0].Set(wxACCEL_CTRL, (int)'Z', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::UNDO));
Expand All @@ -602,33 +604,34 @@ bool MainMenuBar::Load(const FileName &path, wxArrayString &warnings, wxString &
entries[18].Set(wxACCEL_CTRL, (int)'L', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::GHOST_HIGHER_FLOORS));
entries[19].Set(wxACCEL_SHIFT, (int)'I', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_INGAME_BOX));
entries[20].Set(wxACCEL_SHIFT, (int)'L', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_LIGHTS));
entries[21].Set(wxACCEL_SHIFT, (int)'G', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_GRID));
entries[22].Set(wxACCEL_NORMAL, (int)'V', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::HIGHLIGHT_ITEMS));
entries[23].Set(wxACCEL_NORMAL, (int)'F', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_MONSTERS));
entries[24].Set(wxACCEL_NORMAL, (int)'S', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPAWNS_MONSTER));
entries[25].Set(wxACCEL_NORMAL, (int)'X', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_NPCS));
entries[26].Set(wxACCEL_NORMAL, (int)'U', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPAWNS_NPC));
entries[27].Set(wxACCEL_NORMAL, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPECIAL));
entries[28].Set(wxACCEL_SHIFT, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_AS_MINIMAP));
entries[29].Set(wxACCEL_CTRL, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_ONLY_COLORS));
entries[30].Set(wxACCEL_CTRL, (int)'M', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_ONLY_MODIFIED));
entries[31].Set(wxACCEL_CTRL, (int)'H', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_HOUSES));
entries[32].Set(wxACCEL_NORMAL, (int)'O', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_PATHING));
entries[33].Set(wxACCEL_NORMAL, (int)'Y', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_TOOLTIPS));
entries[34].Set(wxACCEL_NORMAL, (int)'L', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_PREVIEW));
entries[35].Set(wxACCEL_NORMAL, (int)'K', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_WALL_HOOKS));
entries[21].Set(wxACCEL_SHIFT, (int)'K', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_LIGHT_STRENGTH));
entries[22].Set(wxACCEL_SHIFT, (int)'G', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_GRID));
entries[23].Set(wxACCEL_NORMAL, (int)'V', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::HIGHLIGHT_ITEMS));
entries[24].Set(wxACCEL_NORMAL, (int)'F', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_MONSTERS));
entries[25].Set(wxACCEL_NORMAL, (int)'S', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPAWNS_MONSTER));
entries[26].Set(wxACCEL_NORMAL, (int)'X', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_NPCS));
entries[27].Set(wxACCEL_NORMAL, (int)'U', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPAWNS_NPC));
entries[28].Set(wxACCEL_NORMAL, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_SPECIAL));
entries[29].Set(wxACCEL_SHIFT, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_AS_MINIMAP));
entries[30].Set(wxACCEL_CTRL, (int)'E', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_ONLY_COLORS));
entries[31].Set(wxACCEL_CTRL, (int)'M', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_ONLY_MODIFIED));
entries[32].Set(wxACCEL_CTRL, (int)'H', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_HOUSES));
entries[33].Set(wxACCEL_NORMAL, (int)'O', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_PATHING));
entries[34].Set(wxACCEL_NORMAL, (int)'Y', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_TOOLTIPS));
entries[35].Set(wxACCEL_NORMAL, (int)'L', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_PREVIEW));
entries[36].Set(wxACCEL_NORMAL, (int)'K', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SHOW_WALL_HOOKS));

// Window
entries[36].Set(wxACCEL_NORMAL, (int)'M', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::WIN_MINIMAP));
entries[37].Set(wxACCEL_NORMAL, (int)'T', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_TERRAIN));
entries[38].Set(wxACCEL_NORMAL, (int)'D', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_DOODAD));
entries[39].Set(wxACCEL_NORMAL, (int)'I', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_ITEM));
entries[40].Set(wxACCEL_NORMAL, (int)'H', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_HOUSE));
entries[41].Set(wxACCEL_NORMAL, (int)'C', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_MONSTER));
entries[42].Set(wxACCEL_NORMAL, (int)'N', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_NPC));
entries[43].Set(wxACCEL_NORMAL, (int)'W', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_WAYPOINT));
entries[44].Set(wxACCEL_NORMAL, (int)'Z', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_ZONES));
entries[45].Set(wxACCEL_NORMAL, (int)'R', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_RAW));
entries[37].Set(wxACCEL_NORMAL, (int)'M', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::WIN_MINIMAP));
entries[38].Set(wxACCEL_NORMAL, (int)'T', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_TERRAIN));
entries[39].Set(wxACCEL_NORMAL, (int)'D', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_DOODAD));
entries[40].Set(wxACCEL_NORMAL, (int)'I', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_ITEM));
entries[41].Set(wxACCEL_NORMAL, (int)'H', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_HOUSE));
entries[42].Set(wxACCEL_NORMAL, (int)'C', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_MONSTER));
entries[43].Set(wxACCEL_NORMAL, (int)'N', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_NPC));
entries[44].Set(wxACCEL_NORMAL, (int)'W', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_WAYPOINT));
entries[45].Set(wxACCEL_NORMAL, (int)'Z', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_ZONES));
entries[46].Set(wxACCEL_NORMAL, (int)'R', static_cast<int>(MAIN_FRAME_MENU) + static_cast<int>(MenuBar::SELECT_RAW));

wxAcceleratorTable accelerator(count, entries);
frame->SetAcceleratorTable(accelerator);
Expand Down Expand Up @@ -2019,6 +2022,7 @@ void MainMenuBar::OnChangeViewSettings(wxCommandEvent &event) {
g_settings.setInteger(Config::TRANSPARENT_ITEMS, IsItemChecked(MenuBar::GHOST_ITEMS));
g_settings.setInteger(Config::SHOW_INGAME_BOX, IsItemChecked(MenuBar::SHOW_INGAME_BOX));
g_settings.setInteger(Config::SHOW_LIGHTS, IsItemChecked(MenuBar::SHOW_LIGHTS));
g_settings.setInteger(Config::SHOW_LIGHT_STRENGTH, IsItemChecked(MenuBar::SHOW_LIGHT_STRENGTH));
g_settings.setInteger(Config::SHOW_GRID, IsItemChecked(MenuBar::SHOW_GRID));
g_settings.setInteger(Config::SHOW_EXTRA, !IsItemChecked(MenuBar::SHOW_EXTRA));

Expand Down
1 change: 1 addition & 0 deletions source/main_menubar.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace MenuBar {
HIGHLIGHT_ITEMS,
SHOW_INGAME_BOX,
SHOW_LIGHTS,
SHOW_LIGHT_STRENGTH,
SHOW_GRID,
SHOW_EXTRA,
SHOW_MONSTERS,
Expand Down
1 change: 1 addition & 0 deletions source/map_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ void MapCanvas::OnPaint(wxPaintEvent &event) {
options.transparent_items = g_settings.getBoolean(Config::TRANSPARENT_ITEMS);
options.show_ingame_box = g_settings.getBoolean(Config::SHOW_INGAME_BOX);
options.show_lights = g_settings.getBoolean(Config::SHOW_LIGHTS);
options.show_light_strength = g_settings.getBoolean(Config::SHOW_LIGHT_STRENGTH);
options.show_grid = g_settings.getInteger(Config::SHOW_GRID);
options.ingame = !g_settings.getBoolean(Config::SHOW_EXTRA);
options.show_all_floors = g_settings.getBoolean(Config::SHOW_ALL_FLOORS);
Expand Down
65 changes: 50 additions & 15 deletions source/map_drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void DrawingOptions::SetDefault() {
transparent_items = false;
show_ingame_box = false;
show_lights = false;
show_light_strength = true;
ingame = false;
dragging = false;

Expand Down Expand Up @@ -86,6 +87,7 @@ void DrawingOptions::SetIngame() {
transparent_items = false;
show_ingame_box = false;
show_lights = false;
show_light_strength = false;
ingame = true;
dragging = false;

Expand Down Expand Up @@ -279,10 +281,6 @@ void MapDrawer::DrawShade(int map_z) {
}

void MapDrawer::DrawMap() {
int center_x = start_x + int(screensize_x * zoom / 64);
int center_y = start_y + int(screensize_y * zoom / 64);
int offset_y = 2;

bool live_client = editor.IsLiveClient();

Brush* brush = g_gui.GetCurrentBrush();
Expand Down Expand Up @@ -1210,6 +1208,10 @@ void MapDrawer::BlitItem(int &draw_x, int &draw_y, const Tile* tile, const Item*
if (options.show_hooks && (type.hookSouth || type.hookEast)) {
DrawHookIndicator(draw_x, draw_y, type);
}

if (!options.ingame && options.show_light_strength) {
DrawLightStrength(draw_x, draw_y, item);
}
}

void MapDrawer::BlitItem(int &draw_x, int &draw_y, const Position &pos, const Item* item, bool ephemeral, int red, int green, int blue, int alpha) {
Expand Down Expand Up @@ -1310,6 +1312,10 @@ void MapDrawer::BlitItem(int &draw_x, int &draw_y, const Position &pos, const It
if (options.show_hooks && (type.hookSouth || type.hookEast) && zoom <= 3.0) {
DrawHookIndicator(draw_x, draw_y, type);
}

if (!options.ingame && options.show_light_strength) {
DrawLightStrength(draw_x, draw_y, item);
}
}

void MapDrawer::BlitSpriteType(int screenx, int screeny, uint32_t spriteid, int red, int green, int blue, int alpha) {
Expand Down Expand Up @@ -1696,6 +1702,27 @@ void MapDrawer::DrawHookIndicator(int x, int y, const ItemType &type) {
glEnable(GL_TEXTURE_2D);
}

void MapDrawer::DrawLightStrength(int x, int y, const Item*&item) {
const SpriteLight &light = item->getLight();

if (light.intensity <= 0) {
return;
}

wxColor lightColor = colorFromEightBit(light.color);
const uint8_t byteR = lightColor.Red();
const uint8_t byteG = lightColor.Green();
const uint8_t byteB = lightColor.Blue();
constexpr uint8_t byteA = 255;

const int startOffset = std::max<int>(16, 32 - light.intensity);
const int sqSize = rme::TileSize - startOffset;
glDisable(GL_TEXTURE_2D);
glBlitSquare(x + startOffset - 2, y + startOffset - 2, 0, 0, 0, byteA, sqSize + 2);
glBlitSquare(x + startOffset - 1, y + startOffset - 1, byteR, byteG, byteB, byteA, sqSize);
glEnable(GL_TEXTURE_2D);
}

void MapDrawer::DrawTileIndicators(TileLocation* location) {
if (!location) {
return;
Expand Down Expand Up @@ -2019,23 +2046,31 @@ void MapDrawer::glBlitTexture(int x, int y, int textureId, int red, int green, i
glEnd();
}

void MapDrawer::glBlitSquare(int x, int y, int red, int green, int blue, int alpha) {
glColor4ub(uint8_t(red), uint8_t(green), uint8_t(blue), uint8_t(alpha));
void MapDrawer::glBlitSquare(int x, int y, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, int size /* = rme::TileSize */) const {
const auto dx = static_cast<double>(x);
const auto dy = static_cast<double>(y);
const auto dSize = static_cast<double>(size);

glColor4ub(red, green, blue, alpha);
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(x + rme::TileSize, y);
glVertex2f(x + rme::TileSize, y + rme::TileSize);
glVertex2f(x, y + rme::TileSize);
glVertex2f(dx, dy);
glVertex2f(dx + dSize, dy);
glVertex2f(dx + dSize, dy + dSize);
glVertex2f(dx, dy + dSize);
glEnd();
}

void MapDrawer::glBlitSquare(int x, int y, const wxColor &color) {
void MapDrawer::glBlitSquare(int x, int y, const wxColor &color, int size /* = rme::TileSize */) const {
const auto dx = static_cast<double>(x);
const auto dy = static_cast<double>(y);
const auto dSize = static_cast<double>(size);

glColor4ub(color.Red(), color.Green(), color.Blue(), color.Alpha());
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(x + rme::TileSize, y);
glVertex2f(x + rme::TileSize, y + rme::TileSize);
glVertex2f(x, y + rme::TileSize);
glVertex2f(dx, dy);
glVertex2f(dx + dSize, dy);
glVertex2f(dx + dSize, dy + dSize);
glVertex2f(dx, dy + dSize);
glEnd();
}

Expand Down
6 changes: 4 additions & 2 deletions source/map_drawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct DrawingOptions {
bool transparent_floors;
bool transparent_items;
bool show_ingame_box;
bool show_light_strength;
bool show_lights;
bool ingame;
bool dragging;
Expand Down Expand Up @@ -158,6 +159,7 @@ class MapDrawer {
void DrawTile(TileLocation* tile);
void DrawBrushIndicator(int x, int y, Brush* brush, uint8_t r, uint8_t g, uint8_t b);
void DrawHookIndicator(int x, int y, const ItemType &type);
void DrawLightStrength(int x, int y, const Item*&item);
void DrawTileIndicators(TileLocation* location);
void DrawIndicator(int x, int y, int indicator, uint8_t r = 255, uint8_t g = 255, uint8_t b = 255, uint8_t a = 255);
void DrawPositionIndicator(int z);
Expand All @@ -181,8 +183,8 @@ class MapDrawer {

void getColor(Brush* brush, const Position &position, uint8_t &r, uint8_t &g, uint8_t &b);
void glBlitTexture(int x, int y, int textureId, int red, int green, int blue, int alpha, bool adjustZoom = false);
void glBlitSquare(int x, int y, int red, int green, int blue, int alpha);
void glBlitSquare(int x, int y, const wxColor &color);
void glBlitSquare(int x, int y, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, int size = rme::TileSize) const;
void glBlitSquare(int x, int y, const wxColor &color, int size = rme::TileSize) const;
void glColor(const wxColor &color);
void glColor(BrushColor color);
void glColorCheck(Brush* brush, const Position &pos);
Expand Down
1 change: 1 addition & 0 deletions source/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void Settings::IO(IOMode mode) {
Int(SHOW_ALL_FLOORS, 1);
Int(SHOW_INGAME_BOX, 0);
Int(SHOW_LIGHTS, 1);
Int(SHOW_LIGHT_STRENGTH, 1);
Int(SHOW_GRID, 0);
Int(SHOW_EXTRA, 1);
Int(SHOW_SHADE, 1);
Expand Down
1 change: 1 addition & 0 deletions source/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace Config {
TRANSPARENT_ITEMS,
SHOW_INGAME_BOX,
SHOW_LIGHTS,
SHOW_LIGHT_STRENGTH,
SHOW_GRID,
SHOW_EXTRA,
SHOW_ALL_FLOORS,
Expand Down

0 comments on commit 12a736d

Please sign in to comment.