diff --git a/NewDialogs/Button.cpp b/NewDialogs/Button.cpp index 882a74d..d5edf22 100644 --- a/NewDialogs/Button.cpp +++ b/NewDialogs/Button.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include #include @@ -5,8 +7,6 @@ using namespace std; #include -#include "../SDLHelpers.h" - #include "Button.h" Button::Button(string text, SDL_Color color, SDL_Rect pos) : Item(pos) { diff --git a/NewDialogs/Checkbox.cpp b/NewDialogs/Checkbox.cpp index 8c58dd9..e66076d 100644 --- a/NewDialogs/Checkbox.cpp +++ b/NewDialogs/Checkbox.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include using namespace std; @@ -5,8 +7,6 @@ using namespace std; #include #include -#include "../SDLHelpers.h" - #include "Checkbox.h" bool isBetween(float a, float b, float c) { diff --git a/NewDialogs/DlgDropDownList.cpp b/NewDialogs/DlgDropDownList.cpp index 8af8106..fd3e69d 100644 --- a/NewDialogs/DlgDropDownList.cpp +++ b/NewDialogs/DlgDropDownList.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include using namespace std; @@ -6,8 +8,6 @@ using namespace std; #include #include -#include "../SDLHelpers.h" - #include "Item.h" #include "Scrollbar.h" #include "Listbox.h" diff --git a/NewDialogs/DlgMainMenu.cpp b/NewDialogs/DlgMainMenu.cpp index 17c013a..d72807c 100644 --- a/NewDialogs/DlgMainMenu.cpp +++ b/NewDialogs/DlgMainMenu.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include #include #include @@ -12,12 +14,9 @@ using namespace std; #include #include -#include "../SDLHelpers.h" - #include "Item.h" #include "Button.h" #include "Dialog.h" -#include "Frame.h" #include "DlgMainMenu.h" diff --git a/NewDialogs/DropDownList.cpp b/NewDialogs/DropDownList.cpp index ec88a20..3c5cd18 100644 --- a/NewDialogs/DropDownList.cpp +++ b/NewDialogs/DropDownList.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include #include @@ -6,8 +8,6 @@ using namespace std; #include #include -#include "../SDLHelpers.h" - #include "DropDownList.h" #include "DlgDropDownList.h" diff --git a/NewDialogs/Listbox.cpp b/NewDialogs/Listbox.cpp index d7074a6..1ef142b 100644 --- a/NewDialogs/Listbox.cpp +++ b/NewDialogs/Listbox.cpp @@ -1,3 +1,5 @@ +#include "../SDLHelpers.h" + #include using namespace std; @@ -5,8 +7,6 @@ using namespace std; #include #include -#include "../SDLHelpers.h" - #include "Listbox.h" Listbox::Listbox(vector list, int item_size, SDL_Rect pos) : Item(pos) { diff --git a/SDLHelpers.h b/SDLHelpers.h index 3743c7b..65880cd 100644 --- a/SDLHelpers.h +++ b/SDLHelpers.h @@ -8,6 +8,10 @@ #include #include +#ifdef SDL_PLATFORM_WINDOWS +#include +#endif + static const char *font_paths[] = {"C:/windows/fonts/", "/usr/share/fonts/TTF/", "./"}; static const short font_path_count = 3; @@ -31,12 +35,24 @@ static SDL_Color getColor(Uint8 r, Uint8 g, Uint8 b) { static TTF_Font *openFont(std::vector fonts, int size) { TTF_Font *font = NULL; for (int x = 0; x < fonts.size(); x++) { +#ifdef SDL_PLATFORM_WINDOWS + TCHAR windir[MAX_PATH]; + GetWindowsDirectory(windir, MAX_PATH); + std::string windir_s(windir); + windir_s.append("/fonts/"); + windir_s.append(fonts[x]); + font = TTF_OpenFont(windir_s.c_str(), size); + if (font) { + return font; + } +#endif for (int y = 0; y < font_path_count; y++) { std::string val(font_paths[y]); val.append(fonts[x]); font = TTF_OpenFont(val.c_str(), size); - if (font) + if (font) { return font; + } } } return NULL;