diff --git a/CDebug.cpp b/CDebug.cpp index b7dcf39..20150ae 100644 --- a/CDebug.cpp +++ b/CDebug.cpp @@ -48,7 +48,7 @@ CDebug::CDebug(void dbgCallback(int), int quitParam) shadingText = nullptr; unknown5Text = nullptr; editorModeText = nullptr; - fontsize = 9; + fontsize = FontSize::Small; MapObj = global::s2->MapObj.get(); map = nullptr; global::s2->RegisterCallback(dbgCallback); diff --git a/CDebug.h b/CDebug.h index 76d1f65..a73dcb3 100644 --- a/CDebug.h +++ b/CDebug.h @@ -63,7 +63,6 @@ class CDebug CFont* shadingText; CFont* unknown5Text; CFont* editorModeText; - // fontsize for debugging window (remember: only 9, 11 or 14) FontSize fontsize; // temporary pointer to Map-Object CMap* MapObj; diff --git a/CIO/CFont.cpp b/CIO/CFont.cpp index 02bf020..e0175ea 100644 --- a/CIO/CFont.cpp +++ b/CIO/CFont.cpp @@ -4,13 +4,8 @@ #include CFont::CFont(std::string text, unsigned x, unsigned y, FontSize fontsize, FontColor color) - : x_(x), y_(y), fontsize_(fontsize), string_(std::move(text)) -{ - // only three sizes are available (in pixels) - initialColor_ = this->color_ = color; - callback = nullptr; - clickedParam = 0; -} + : x_(x), y_(y), string_(std::move(text)), fontsize_(fontsize), color_(color), initialColor_(color), clickedParam(0) +{} void CFont::setPos(Position pos) { @@ -212,7 +207,7 @@ void CFont::writeText() unsigned pixel_ctr_w = 0; unsigned pixel_ctr_w_tmp = 0; const unsigned lineHeight = getLineHeight(fontsize_); - unsigned pixel_ctr_h = static_cast(fontsize_); + auto pixel_ctr_h = static_cast(fontsize_); bool pixel_count_loop = true; // counter for the drawed pixels (cause we dont want to draw outside of the surface) Position pos{0, 0}; diff --git a/CIO/CFont.h b/CIO/CFont.h index 3b38199..2cee101 100644 --- a/CIO/CFont.h +++ b/CIO/CFont.h @@ -18,7 +18,7 @@ class CFont Uint16 w; Uint16 h; std::string string_; - FontSize fontsize_; //== Uint16 h; + FontSize fontsize_; FontColor color_, initialColor_; std::function callback; int clickedParam; diff --git a/callbacks.cpp b/callbacks.cpp index 2b8fdb3..c390480 100644 --- a/callbacks.cpp +++ b/callbacks.cpp @@ -2837,7 +2837,7 @@ void callback::viewer(int Param) { const auto infos = helpers::format("index=%d, w=%d, h=%d, nx=%d, ny=%d", index, global::bmpArray[index].w, global::bmpArray[index].h, global::bmpArray[index].nx, global::bmpArray[index].ny); - PicInfosText = WNDViewer->addText(infos, 220, 3, 14, FontColor::Red); + PicInfosText = WNDViewer->addText(infos, 220, 3, FontSize::Large, FontColor::Red); } break; @@ -2955,7 +2955,7 @@ void callback::submenu1(int Param) picObject = SubMenu->addPicture(submenu1, PICOBJECT, 200, 30, MIS0BOBS_SHIP); picObject->setMotionParams(PICOBJECTENTRY, PICOBJECTLEAVE); // text block with \n - SubMenu->addText("\nTextblock:\n\nNeue Zeile\nNoch eine neue Zeile", 400, 200, 14); + SubMenu->addText("\nTextblock:\n\nNeue Zeile\nNoch eine neue Zeile", 400, 200, FontSize::Large); testTextfield = SubMenu->addTextfield(400, 300, 10, 3); testSelectBox = SubMenu->addSelectBox(Point16(500, 500), Extent16(300, 200)); testSelectBox->addOption("Erste Option", submenu1, SELECTBOX_OPTION1); @@ -2991,9 +2991,9 @@ void callback::submenu1(int Param) break; case GREATMOON: - SubMenu->addText("Title!", 300, 10, 14); + SubMenu->addText("Title!", 300, 10, FontSize::Large); SubMenu->addText(helpers::format("Window X: %d Window Y: %d", global::s2->GameResolution.x, global::s2->GameResolution.y), 10, - 10, 14); + 10, FontSize::Large); break; case SMALLMOON: @@ -3013,11 +3013,11 @@ void callback::submenu1(int Param) testWindow = global::s2->RegisterWindow( std::make_unique(submenu1, TESTWINDOWQUITMESSAGE, Position(5, 5), Extent(350, 240), "Window", WINDOW_GREEN1, WINDOW_CLOSE | WINDOW_MOVE | WINDOW_MINIMIZE | WINDOW_RESIZE)); - testWindow->addText("Text inside the window", 10, 10, 14); + testWindow->addText("Text inside the window", 10, 10, FontSize::Large); testWindow->addButton(submenu1, -10, 150, 100, 210, 30, BUTTON_GREEN2, "Button inside the window"); testWindowPicture = testWindow->addPicture(submenu1, TESTWINDOWPICTURE, 10, 60, MIS2BOBS_FORTRESS); testWindowPicture->setMotionParams(TESTWINDOWPICTUREENTRY, TESTWINDOWPICTURELEAVE); - testTextfield_testWindow = testWindow->addTextfield(130, 30, 10, 3, 14, FontColor::Red, BUTTON_GREY, true); + testTextfield_testWindow = testWindow->addTextfield(130, 30, 10, 3, FontSize::Large, FontColor::Red, BUTTON_GREY, true); testTextfield_testWindow->setText( "This is a very long test text in order to destroy the text field completely once and for all"); } @@ -3026,14 +3026,14 @@ void callback::submenu1(int Param) testWindow2 = global::s2->RegisterWindow( std::make_unique(submenu1, TESTWINDOW2QUITMESSAGE, Position(200, 5), Extent(350, 240), "Another Window", WINDOW_GREEN1, WINDOW_CLOSE | WINDOW_MOVE | WINDOW_MINIMIZE | WINDOW_RESIZE)); - testWindow2->addText("Text inside the window", 50, 40, 9); + testWindow2->addText("Text inside the window", 50, 40, FontSize::Small); testWindow2->addButton(submenu1, -10, 100, 100, 100, 20, BUTTON_GREEN2, "Button"); } break; case GREATMOONENTRY: if(!greatMoonText) - greatMoonText = SubMenu->addText("Test-Text", 100, 10, 14); + greatMoonText = SubMenu->addText("Test-Text", 100, 10, FontSize::Large); break; case GREATMOONLEAVE: @@ -3054,7 +3054,7 @@ void callback::submenu1(int Param) case PICOBJECTENTRY: if(!greatMoonText) - greatMoonText = SubMenu->addText("Test-Text", 100, 10, 14); + greatMoonText = SubMenu->addText("Test-Text", 100, 10, FontSize::Large); break; case PICOBJECTLEAVE: @@ -3068,7 +3068,7 @@ void callback::submenu1(int Param) case TESTWINDOWPICTURE: assert(testWindow); if(!testWindowText) - testWindowText = testWindow->addText("Clicked on castle", 10, 200, 11); + testWindowText = testWindow->addText("Clicked on castle", 10, 200, FontSize::Medium); else { testWindow->delText(testWindowText); @@ -3083,7 +3083,7 @@ void callback::submenu1(int Param) testWindow->delText(testWindowText2); testWindowText2 = nullptr; } - testWindowText2 = testWindow->addText("Bildbereich betreten", 10, 220, 11); + testWindowText2 = testWindow->addText("Bildbereich betreten", 10, 220, FontSize::Medium); break; case TESTWINDOWPICTURELEAVE: @@ -3093,7 +3093,7 @@ void callback::submenu1(int Param) testWindow->delText(testWindowText2); testWindowText2 = nullptr; } - testWindowText2 = testWindow->addText("Bildbereich verlassen", 10, 220, 11); + testWindowText2 = testWindow->addText("Bildbereich verlassen", 10, 220, FontSize::Medium); break; case TESTWINDOWQUITMESSAGE: @@ -3118,7 +3118,7 @@ void callback::submenu1(int Param) } if(!counterText) { - counterText = SubMenu->addText(helpers::format("counter: %d", counter), 100, 20, 9); + counterText = SubMenu->addText(helpers::format("counter: %d", counter), 100, 20, FontSize::Small); } if(TextFrom_testTextfield) @@ -3126,7 +3126,8 @@ void callback::submenu1(int Param) SubMenu->delText(TextFrom_testTextfield); TextFrom_testTextfield = nullptr; } - TextFrom_testTextfield = SubMenu->addText("Der Text im Textfeld lautet: " + testTextfield->getText(), 200, 400, 14); + TextFrom_testTextfield = + SubMenu->addText("Der Text im Textfeld lautet: " + testTextfield->getText(), 200, 400, FontSize::Large); } counter++; break;