diff --git a/data/menubar.xml b/data/menubar.xml index 9dfc37b0..1b6c50a9 100644 --- a/data/menubar.xml +++ b/data/menubar.xml @@ -129,7 +129,10 @@ - + + + + diff --git a/source/main_menubar.cpp b/source/main_menubar.cpp index 42a33828..9606e77e 100644 --- a/source/main_menubar.cpp +++ b/source/main_menubar.cpp @@ -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); @@ -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)); @@ -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(MAIN_FRAME_MENU) + static_cast(MenuBar::UNDO)); @@ -602,33 +604,34 @@ bool MainMenuBar::Load(const FileName &path, wxArrayString &warnings, wxString & entries[18].Set(wxACCEL_CTRL, (int)'L', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::GHOST_HIGHER_FLOORS)); entries[19].Set(wxACCEL_SHIFT, (int)'I', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_INGAME_BOX)); entries[20].Set(wxACCEL_SHIFT, (int)'L', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_LIGHTS)); - entries[21].Set(wxACCEL_SHIFT, (int)'G', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_GRID)); - entries[22].Set(wxACCEL_NORMAL, (int)'V', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::HIGHLIGHT_ITEMS)); - entries[23].Set(wxACCEL_NORMAL, (int)'F', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_MONSTERS)); - entries[24].Set(wxACCEL_NORMAL, (int)'S', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPAWNS_MONSTER)); - entries[25].Set(wxACCEL_NORMAL, (int)'X', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_NPCS)); - entries[26].Set(wxACCEL_NORMAL, (int)'U', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPAWNS_NPC)); - entries[27].Set(wxACCEL_NORMAL, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPECIAL)); - entries[28].Set(wxACCEL_SHIFT, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_AS_MINIMAP)); - entries[29].Set(wxACCEL_CTRL, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_ONLY_COLORS)); - entries[30].Set(wxACCEL_CTRL, (int)'M', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_ONLY_MODIFIED)); - entries[31].Set(wxACCEL_CTRL, (int)'H', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_HOUSES)); - entries[32].Set(wxACCEL_NORMAL, (int)'O', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_PATHING)); - entries[33].Set(wxACCEL_NORMAL, (int)'Y', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_TOOLTIPS)); - entries[34].Set(wxACCEL_NORMAL, (int)'L', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_PREVIEW)); - entries[35].Set(wxACCEL_NORMAL, (int)'K', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_WALL_HOOKS)); + entries[21].Set(wxACCEL_SHIFT, (int)'K', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_LIGHT_STRENGTH)); + entries[22].Set(wxACCEL_SHIFT, (int)'G', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_GRID)); + entries[23].Set(wxACCEL_NORMAL, (int)'V', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::HIGHLIGHT_ITEMS)); + entries[24].Set(wxACCEL_NORMAL, (int)'F', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_MONSTERS)); + entries[25].Set(wxACCEL_NORMAL, (int)'S', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPAWNS_MONSTER)); + entries[26].Set(wxACCEL_NORMAL, (int)'X', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_NPCS)); + entries[27].Set(wxACCEL_NORMAL, (int)'U', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPAWNS_NPC)); + entries[28].Set(wxACCEL_NORMAL, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_SPECIAL)); + entries[29].Set(wxACCEL_SHIFT, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_AS_MINIMAP)); + entries[30].Set(wxACCEL_CTRL, (int)'E', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_ONLY_COLORS)); + entries[31].Set(wxACCEL_CTRL, (int)'M', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_ONLY_MODIFIED)); + entries[32].Set(wxACCEL_CTRL, (int)'H', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_HOUSES)); + entries[33].Set(wxACCEL_NORMAL, (int)'O', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_PATHING)); + entries[34].Set(wxACCEL_NORMAL, (int)'Y', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_TOOLTIPS)); + entries[35].Set(wxACCEL_NORMAL, (int)'L', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_PREVIEW)); + entries[36].Set(wxACCEL_NORMAL, (int)'K', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SHOW_WALL_HOOKS)); // Window - entries[36].Set(wxACCEL_NORMAL, (int)'M', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::WIN_MINIMAP)); - entries[37].Set(wxACCEL_NORMAL, (int)'T', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_TERRAIN)); - entries[38].Set(wxACCEL_NORMAL, (int)'D', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_DOODAD)); - entries[39].Set(wxACCEL_NORMAL, (int)'I', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_ITEM)); - entries[40].Set(wxACCEL_NORMAL, (int)'H', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_HOUSE)); - entries[41].Set(wxACCEL_NORMAL, (int)'C', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_MONSTER)); - entries[42].Set(wxACCEL_NORMAL, (int)'N', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_NPC)); - entries[43].Set(wxACCEL_NORMAL, (int)'W', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_WAYPOINT)); - entries[44].Set(wxACCEL_NORMAL, (int)'Z', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_ZONES)); - entries[45].Set(wxACCEL_NORMAL, (int)'R', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_RAW)); + entries[37].Set(wxACCEL_NORMAL, (int)'M', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::WIN_MINIMAP)); + entries[38].Set(wxACCEL_NORMAL, (int)'T', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_TERRAIN)); + entries[39].Set(wxACCEL_NORMAL, (int)'D', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_DOODAD)); + entries[40].Set(wxACCEL_NORMAL, (int)'I', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_ITEM)); + entries[41].Set(wxACCEL_NORMAL, (int)'H', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_HOUSE)); + entries[42].Set(wxACCEL_NORMAL, (int)'C', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_MONSTER)); + entries[43].Set(wxACCEL_NORMAL, (int)'N', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_NPC)); + entries[44].Set(wxACCEL_NORMAL, (int)'W', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_WAYPOINT)); + entries[45].Set(wxACCEL_NORMAL, (int)'Z', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_ZONES)); + entries[46].Set(wxACCEL_NORMAL, (int)'R', static_cast(MAIN_FRAME_MENU) + static_cast(MenuBar::SELECT_RAW)); wxAcceleratorTable accelerator(count, entries); frame->SetAcceleratorTable(accelerator); @@ -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)); diff --git a/source/main_menubar.h b/source/main_menubar.h index b5042bd7..0719f90a 100644 --- a/source/main_menubar.h +++ b/source/main_menubar.h @@ -105,6 +105,7 @@ namespace MenuBar { HIGHLIGHT_ITEMS, SHOW_INGAME_BOX, SHOW_LIGHTS, + SHOW_LIGHT_STRENGTH, SHOW_GRID, SHOW_EXTRA, SHOW_MONSTERS, diff --git a/source/map_display.cpp b/source/map_display.cpp index 3ff31f9f..1b735b7e 100644 --- a/source/map_display.cpp +++ b/source/map_display.cpp @@ -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); diff --git a/source/map_drawer.cpp b/source/map_drawer.cpp index e48c337d..5bf8c43a 100644 --- a/source/map_drawer.cpp +++ b/source/map_drawer.cpp @@ -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; @@ -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; @@ -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(); @@ -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) { @@ -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) { @@ -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(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; @@ -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(x); + const auto dy = static_cast(y); + const auto dSize = static_cast(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(x); + const auto dy = static_cast(y); + const auto dSize = static_cast(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(); } diff --git a/source/map_drawer.h b/source/map_drawer.h index 9951f1c7..4f312bc3 100644 --- a/source/map_drawer.h +++ b/source/map_drawer.h @@ -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; @@ -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); @@ -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); diff --git a/source/settings.cpp b/source/settings.cpp index 6d8d1bf0..edfb1ef4 100644 --- a/source/settings.cpp +++ b/source/settings.cpp @@ -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); diff --git a/source/settings.h b/source/settings.h index 4a5b61b7..4cdb696f 100644 --- a/source/settings.h +++ b/source/settings.h @@ -43,6 +43,7 @@ namespace Config { TRANSPARENT_ITEMS, SHOW_INGAME_BOX, SHOW_LIGHTS, + SHOW_LIGHT_STRENGTH, SHOW_GRID, SHOW_EXTRA, SHOW_ALL_FLOORS,