mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
only show missing file dialog when running game (not launcher) and default.zip is missing.
Also use '1 hour' instead of '1 hours' in update menu
This commit is contained in:
parent
e47c45bc30
commit
8f7c759d7d
@ -1232,6 +1232,19 @@ static void UpdatesScreen_Draw(struct LScreen* s) {
|
|||||||
midX - 160, midY - 5, 320, 1);
|
midX - 160, midY - 5, 320, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CC_NOINLINE static void UpdatesScreen_FormatTime(String* str, char* type, int delta, int unit) {
|
||||||
|
delta /= unit;
|
||||||
|
String_AppendInt(str, delta);
|
||||||
|
String_Append(str, ' ');
|
||||||
|
String_AppendConst(str, type);
|
||||||
|
|
||||||
|
if (delta > 1) {
|
||||||
|
String_AppendConst(str, "s ago");
|
||||||
|
} else {
|
||||||
|
String_AppendConst(str, " ago");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdatesScreen_Format(struct LLabel* lbl, const char* prefix, TimeMS time) {
|
static void UpdatesScreen_Format(struct LLabel* lbl, const char* prefix, TimeMS time) {
|
||||||
String str; char buffer[STRING_SIZE];
|
String str; char buffer[STRING_SIZE];
|
||||||
TimeMS now;
|
TimeMS now;
|
||||||
@ -1246,16 +1259,13 @@ static void UpdatesScreen_Format(struct LLabel* lbl, const char* prefix, TimeMS
|
|||||||
int delta = (int)(now - time) / 1000;
|
int delta = (int)(now - time) / 1000;
|
||||||
|
|
||||||
if (delta < SECS_PER_MIN) {
|
if (delta < SECS_PER_MIN) {
|
||||||
String_Format1(&str, "%i seconds ago", &delta);
|
UpdatesScreen_FormatTime(&str, "second", delta, 1);
|
||||||
} else if (delta < SECS_PER_HOUR) {
|
} else if (delta < SECS_PER_HOUR) {
|
||||||
delta /= SECS_PER_MIN;
|
UpdatesScreen_FormatTime(&str, "minute", delta, SECS_PER_MIN);
|
||||||
String_Format1(&str, "%i minutes ago", &delta);
|
|
||||||
} else if (delta < SECS_PER_DAY) {
|
} else if (delta < SECS_PER_DAY) {
|
||||||
delta /= SECS_PER_HOUR;
|
UpdatesScreen_FormatTime(&str, "hour", delta, SECS_PER_HOUR);
|
||||||
String_Format1(&str, "%i hours ago", &delta);
|
|
||||||
} else {
|
} else {
|
||||||
delta /= SECS_PER_DAY;
|
UpdatesScreen_FormatTime(&str, "day", delta, SECS_PER_DAY);
|
||||||
String_Format1(&str, "%i days ago", &delta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LLabel_SetText(lbl, &str);
|
LLabel_SetText(lbl, &str);
|
||||||
|
@ -906,7 +906,7 @@ void Font_GetNames(StringsBuffer* buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String Font_Lookup(const String* fontName, const char type) {
|
static String Font_LookupOf(const String* fontName, const char type) {
|
||||||
String name; char nameBuffer[STRING_SIZE + 2];
|
String name; char nameBuffer[STRING_SIZE + 2];
|
||||||
String_InitArray(name, nameBuffer);
|
String_InitArray(name, nameBuffer);
|
||||||
|
|
||||||
@ -914,6 +914,17 @@ static String Font_Lookup(const String* fontName, const char type) {
|
|||||||
return EntryList_UNSAFE_Get(&font_list, &name);
|
return EntryList_UNSAFE_Get(&font_list, &name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String Font_Lookup(const String* fontName, int style) {
|
||||||
|
String path;
|
||||||
|
if (!font_list.Entries.Count) Font_Init();
|
||||||
|
path = String_Empty;
|
||||||
|
|
||||||
|
if (style & FONT_STYLE_BOLD) path = Font_Lookup(fontName, 'B');
|
||||||
|
if (style & FONT_STYLE_ITALIC) path = Font_Lookup(fontName, 'I');
|
||||||
|
|
||||||
|
return Font_Lookup(fontName, 'R');
|
||||||
|
}
|
||||||
|
|
||||||
void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
|
void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
|
||||||
String path;
|
String path;
|
||||||
FT_Stream stream;
|
FT_Stream stream;
|
||||||
@ -924,13 +935,7 @@ void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
|
|||||||
desc->Size = size;
|
desc->Size = size;
|
||||||
desc->Style = style;
|
desc->Style = style;
|
||||||
|
|
||||||
if (!font_list.Entries.Count) Font_Init();
|
path = Font_Lookup(fontName, style);
|
||||||
path = String_Empty;
|
|
||||||
|
|
||||||
if (style & FONT_STYLE_BOLD) path = Font_Lookup(fontName, 'B');
|
|
||||||
if (style & FONT_STYLE_ITALIC) path = Font_Lookup(fontName, 'I');
|
|
||||||
|
|
||||||
if (!path.length) path = Font_Lookup(fontName, 'R');
|
|
||||||
if (!path.length) ErrorHandler_Fail("Unknown font");
|
if (!path.length) ErrorHandler_Fail("Unknown font");
|
||||||
|
|
||||||
stream = Mem_AllocCleared(1, sizeof(FT_StreamRec), "leaky font"); /* TODO: LEAKS MEMORY!!! */
|
stream = Mem_AllocCleared(1, sizeof(FT_StreamRec), "leaky font"); /* TODO: LEAKS MEMORY!!! */
|
||||||
@ -1163,7 +1168,7 @@ static void* FT_ReallocWrapper(FT_Memory memory, long cur_size, long new_size, v
|
|||||||
#define FONT_CACHE_FILE "fontcache.txt"
|
#define FONT_CACHE_FILE "fontcache.txt"
|
||||||
static void Font_Init(void) {
|
static void Font_Init(void) {
|
||||||
#ifdef CC_BUILD_WIN
|
#ifdef CC_BUILD_WIN
|
||||||
const static String dir = String_FromConst("C:\\Windows\\fonts");
|
const static String dir = String_FromConst("C:\\Windows\\Fonts");
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_BUILD_NIX
|
#ifdef CC_BUILD_NIX
|
||||||
const static String dir = String_FromConst("/usr/share/fonts");
|
const static String dir = String_FromConst("/usr/share/fonts");
|
||||||
|
@ -40,10 +40,16 @@ int main_imdct() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void Program_RunGame(void) {
|
static void Program_RunGame(void) {
|
||||||
|
const static String defPath = String_FromConst("texpacks/default.zip");
|
||||||
String title; char titleBuffer[STRING_SIZE];
|
String title; char titleBuffer[STRING_SIZE];
|
||||||
struct DisplayDevice device;
|
struct DisplayDevice device;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
if (!File_Exists(&defPath)) {
|
||||||
|
Window_ShowDialog("Missing file",
|
||||||
|
"default.zip is missing, try running launcher first.\n\nThe game will still run, but without any textures");
|
||||||
|
}
|
||||||
|
|
||||||
device = DisplayDevice_Default;
|
device = DisplayDevice_Default;
|
||||||
width = Options_GetInt(OPT_WINDOW_WIDTH, 0, device.Bounds.Width, 0);
|
width = Options_GetInt(OPT_WINDOW_WIDTH, 0, device.Bounds.Width, 0);
|
||||||
height = Options_GetInt(OPT_WINDOW_HEIGHT, 0, device.Bounds.Height, 0);
|
height = Options_GetInt(OPT_WINDOW_HEIGHT, 0, device.Bounds.Height, 0);
|
||||||
@ -60,7 +66,6 @@ static void Program_RunGame(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
const static String defPath = String_FromConst("texpacks/default.zip");
|
|
||||||
String args[PROGRAM_MAX_CMDARGS];
|
String args[PROGRAM_MAX_CMDARGS];
|
||||||
int argsCount;
|
int argsCount;
|
||||||
uint8_t ip[4];
|
uint8_t ip[4];
|
||||||
@ -82,11 +87,6 @@ int main(int argc, char** argv) {
|
|||||||
Utils_EnsureDirectory("maps");
|
Utils_EnsureDirectory("maps");
|
||||||
Utils_EnsureDirectory("texpacks");
|
Utils_EnsureDirectory("texpacks");
|
||||||
Utils_EnsureDirectory("texturecache");
|
Utils_EnsureDirectory("texturecache");
|
||||||
|
|
||||||
if (!File_Exists(&defPath)) {
|
|
||||||
Window_ShowDialog("Missing file",
|
|
||||||
"default.zip is missing, try running launcher first.\n\nThe game will still run, but without any textures");
|
|
||||||
}
|
|
||||||
Options_Load();
|
Options_Load();
|
||||||
|
|
||||||
if (argsCount == 0) {
|
if (argsCount == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user