Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions FeLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ else()
message(STATUS "Using SDL1")
endif()

# libcurl, for sending/fetching high-scores to/from a global high-score server.
find_package(CURL)
if(CURL_FOUND)
message(STATUS "Using libcurl ${CURL_VERSION_STRING}")
target_compile_definitions(FeLib PUBLIC USE_HIGHSCORE_SERVER)
else()
message(WARNING "libcurl not found, global high-score submissions will be disabled")
endif()

if(MSVC)
# Not very pretty solution. This finds SDL2.dll from SDL2.lib path, so that it can be installed where ivan.exe will end up.
message("SDL2_LIBRARY ${SDL2_LIBRARY}")
Expand Down Expand Up @@ -51,5 +60,6 @@ if(NOT PNG_FOUND)
endif()

target_include_directories(FeLib PUBLIC Include)
target_include_directories(FeLib SYSTEM PUBLIC ${SDL2_INCLUDE_DIR} PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries(FeLib ${SDL2_LIBRARY} ${PNG_LIBRARIES})
target_include_directories(FeLib SYSTEM PUBLIC ${SDL2_INCLUDE_DIR}
PRIVATE ${PNG_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
target_link_libraries(FeLib ${SDL2_LIBRARY} ${PNG_LIBRARIES} ${CURL_LIBRARIES})
2 changes: 2 additions & 0 deletions FeLib/Include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class configsystem
static void Show(void (*)() = 0, void (*)(felist&) = 0, truth = false);
static void AddOption(configoption*);
static void NormalStringDisplayer(const stringoption*, festring&);
static void SecretStringDisplayer(const stringoption*, festring&);
static void NormalNumberDisplayer(const numberoption*, festring&);
static void NormalTruthDisplayer(const truthoption*, festring&);
static void NormalCycleDisplayer(const cycleoption*, festring&);
Expand All @@ -41,6 +42,7 @@ class configsystem
static truth NormalTruthChangeInterface(truthoption*);
static truth NormalCycleChangeInterface(cycleoption*);
static void NormalStringChanger(stringoption*, cfestring&);
static void SecretStringChanger(stringoption*, cfestring&);
static void NormalNumberChanger(numberoption*, long);
static void NormalTruthChanger(truthoption*, truth);
static void NormalCycleChanger(cycleoption*, long);
Expand Down
2 changes: 1 addition & 1 deletion FeLib/Include/feio.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class iosystem
static festring ContinueMenu(col16, col16, cfestring&);
static int StringQuestion(festring&, cfestring&, v2, col16,
festring::sizetype, festring::sizetype,
truth, truth, stringkeyhandler = 0);
truth, truth, stringkeyhandler = 0, truth = false);
static long NumberQuestion(cfestring&, v2, col16,
truth, truth = false);
static long ScrollBarQuestion(cfestring&, v2, long, long, long,
Expand Down
1 change: 1 addition & 0 deletions FeLib/Include/felibdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ inline int GetMinColor24(col24 Color)
#define LIST_WAS_EMPTY 0xFFFF
#define ESCAPED 0xFFFE
#define NOTHING_SELECTED 0xFFFD
#define UNSELECTABLE_SELECT 0xFFFC

#define NO_LIMIT 0xFFFF

Expand Down
21 changes: 18 additions & 3 deletions FeLib/Include/hscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@

class festring;

enum highscoreview
{
LOCAL,
GLOBAL
};

class highscore
{
public:
highscore(cfestring& = HIGH_SCORE_FILENAME);
truth Add(long, cfestring&);
void Draw() const;
truth Add(long, cfestring&, cfestring&, cfestring&, cfestring&);
void Draw(cfestring&);
void Save(cfestring& = HIGH_SCORE_FILENAME) const;
void Load(cfestring& = HIGH_SCORE_FILENAME);
truth LastAddFailed() const;
Expand All @@ -47,13 +53,22 @@ class highscore
void Clear();
truth CheckVersion() const;
private:
truth Add(long, cfestring&, time_t, long);
truth Add(long, cfestring&, time_t, long, cfestring&, cfestring&, cfestring&);
void ToggleBetweenLocalAndGlobalView() { View = static_cast<highscoreview>(!View); }
std::vector<festring> Entry;
std::vector<long> Score;
std::vector<time_t> Time;
std::vector<long> RandomID;
std::vector<festring> GlobalEntry;
std::vector<long> GlobalScore;
std::vector<time_t> GlobalTime;
int LastAdd;
ushort Version;
static highscoreview View;
};

festring FetchAuthToken(cfestring& HighScoreServerURL,
cfestring& HighScoreServerUsername,
cfestring& HighScoreServerPassword);

#endif
7 changes: 7 additions & 0 deletions FeLib/Source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ void configsystem::NormalStringDisplayer(const stringoption* O,
Entry << '-';
}

void configsystem::SecretStringDisplayer(const stringoption* O,
festring& Entry)
{
if(O->Value.IsEmpty())
Entry << "not set";
}

void configsystem::NormalNumberDisplayer(const numberoption* O,
festring& Entry)
{
Expand Down
10 changes: 6 additions & 4 deletions FeLib/Source/feio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ int iosystem::StringQuestion(festring& Input,
festring::sizetype MinLetters,
festring::sizetype MaxLetters,
truth Fade, truth AllowExit,
stringkeyhandler StringKeyHandler)
stringkeyhandler StringKeyHandler,
truth SecretInput)
{
v2 V(RES.X, 10); ///???????????
bitmap BackUp(V, 0);
Expand All @@ -303,7 +304,8 @@ int iosystem::StringQuestion(festring& Input,
bitmap Buffer(RES, 0);
Buffer.ActivateFastFlag();
FONT->Printf(&Buffer, Pos, Color, "%s", Topic.CStr());
FONT->Printf(&Buffer, v2(Pos.X, Pos.Y + 10), Color, "%s", Input.CStr());
FONT->Printf(&Buffer, v2(Pos.X, Pos.Y + 10), Color, "%s",
SecretInput ? festring(Input.GetSize(), '*').CStr() : Input.CStr());
Buffer.FadeToScreen();
}
else
Expand All @@ -317,8 +319,8 @@ int iosystem::StringQuestion(festring& Input,
{
B.Bitmap = DOUBLE_BUFFER;
BackUp.NormalBlit(B);
FONT->Printf(DOUBLE_BUFFER, v2(Pos.X, Pos.Y + 10),
Color, "%s", Input.CStr());
FONT->Printf(DOUBLE_BUFFER, v2(Pos.X, Pos.Y + 10), Color, "%s",
SecretInput ? festring(Input.GetSize(), '*').CStr() : Input.CStr());
FONT->Printf(DOUBLE_BUFFER, v2(Pos.X, Pos.Y + 11),
Color, "%*c", CursorPos + 1, '_');

Expand Down
11 changes: 9 additions & 2 deletions FeLib/Source/felist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,17 @@ uint felist::Draw()
continue;
}

if(Flags & SELECTABLE && Pressed == KEY_ENTER)
if(Pressed == KEY_ENTER)
{
Return = Selected;
if(Flags & SELECTABLE)
Return = Selected;
#ifdef USE_HIGHSCORE_SERVER
else
// Used by the hall of fame to toggle between local and global scores.
Return = UNSELECTABLE_SELECT;

break;
#endif
}

if(Pressed == KEY_ESC)
Expand Down
Loading