Skip to content

Commit

Permalink
Rename remaining Font constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jun 8, 2020
1 parent da66a3a commit 56e7aad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion CDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions CIO/CFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
#include <cassert>

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)
{
Expand Down Expand Up @@ -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<unsigned>(fontsize_);
auto pixel_ctr_h = static_cast<unsigned>(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};
Expand Down
2 changes: 1 addition & 1 deletion CIO/CFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CFont
Uint16 w;
Uint16 h;
std::string string_;
FontSize fontsize_; //== Uint16 h;
FontSize fontsize_;
FontColor color_, initialColor_;
std::function<void(int)> callback;
int clickedParam;
Expand Down
29 changes: 15 additions & 14 deletions callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand All @@ -3013,11 +3013,11 @@ void callback::submenu1(int Param)
testWindow = global::s2->RegisterWindow(
std::make_unique<CWindow>(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");
}
Expand All @@ -3026,14 +3026,14 @@ void callback::submenu1(int Param)
testWindow2 = global::s2->RegisterWindow(
std::make_unique<CWindow>(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:
Expand All @@ -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:
Expand All @@ -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);
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -3118,15 +3118,16 @@ 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)
{
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;
Expand Down

0 comments on commit 56e7aad

Please sign in to comment.