Fixed relative file paths
parent
1fa199512d
commit
376349b922
|
@ -113,10 +113,10 @@ static glyph_atlas *CreateGlyphAtlas(vn_render_commands *RenderCommands,
|
||||||
Atlas->RenderCommands = RenderCommands;
|
Atlas->RenderCommands = RenderCommands;
|
||||||
Atlas->Texture = RenderCommands->AllocateTexture(V2S(BitmapSize, BitmapSize), Render_TextureFormat_R8, 0);
|
Atlas->Texture = RenderCommands->AllocateTexture(V2S(BitmapSize, BitmapSize), Render_TextureFormat_R8, 0);
|
||||||
|
|
||||||
Atlas->Fonts[Font_Regular].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Roboto-Regular.ttf"));
|
Atlas->Fonts[Font_Regular].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Roboto-Regular.ttf"));
|
||||||
Atlas->Fonts[Font_Bold].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Roboto-Bold.ttf"));
|
Atlas->Fonts[Font_Bold].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Roboto-Bold.ttf"));
|
||||||
Atlas->Fonts[Font_Monospace].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Liberation-Mono.ttf"));
|
Atlas->Fonts[Font_Monospace].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Liberation-Mono.ttf"));
|
||||||
Atlas->Fonts[Font_Icons].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/icons.ttf"));
|
Atlas->Fonts[Font_Icons].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/icons.ttf"));
|
||||||
|
|
||||||
for(s32 FontIndex = 0;
|
for(s32 FontIndex = 0;
|
||||||
FontIndex < Font_Count;
|
FontIndex < Font_Count;
|
||||||
|
|
|
@ -44,6 +44,28 @@ inline string MakeStringFromCString(char *Data)
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline b32 AreEqual(string A, string B)
|
||||||
|
{
|
||||||
|
b32 Result = false;
|
||||||
|
if(A.Count == B.Count)
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
for(s64 Index = 0;
|
||||||
|
Index < A.Count;
|
||||||
|
++Index)
|
||||||
|
{
|
||||||
|
if(A.Data[Index] != B.Data[Index])
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
|
||||||
inline s64 FirstIndexOf(string String, char Char)
|
inline s64 FirstIndexOf(string String, char Char)
|
||||||
{
|
{
|
||||||
s64 Result = -1;
|
s64 Result = -1;
|
||||||
|
@ -76,25 +98,23 @@ inline s64 LastIndexOf(string String, char Char)
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline b32 AreEqual(string A, string B)
|
inline s64 LastIndexOf(string String, string Substring)
|
||||||
{
|
{
|
||||||
b32 Result = false;
|
s64 Result = -1;
|
||||||
if(A.Count == B.Count)
|
if(String.Count >= Substring.Count)
|
||||||
{
|
{
|
||||||
Result = true;
|
for(s64 Index = String.Count-Substring.Count;
|
||||||
|
Index >= 0;
|
||||||
for(s64 Index = 0;
|
--Index)
|
||||||
Index < A.Count;
|
|
||||||
++Index)
|
|
||||||
{
|
{
|
||||||
if(A.Data[Index] != B.Data[Index])
|
string ToCheck = MakeString((char *)String.Data + Index, Substring.Count);
|
||||||
|
if(AreEqual(ToCheck, Substring))
|
||||||
{
|
{
|
||||||
Result = false;
|
Result = Index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,12 @@ static PLATFORM_OPEN_FILE(Win32_OpenFile)
|
||||||
CreationAttributes = OPEN_EXISTING;
|
CreationAttributes = OPEN_EXISTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FullPath = Path;
|
temporary_memory Scratch = GetScratch(0, 0);
|
||||||
|
|
||||||
HANDLE File = CreateFileA((char *)Path.Data, DesiredAccess, 0, 0, CreationAttributes, 0, 0);
|
string FullPath = PushFormat(Scratch.Arena, "%S\\%S", Global_Win32State.ContentsPath, Path);
|
||||||
|
HANDLE File = CreateFileA((char *)FullPath.Data, DesiredAccess, 0, 0, CreationAttributes, 0, 0);
|
||||||
|
|
||||||
|
ReleaseScratch(Scratch);
|
||||||
|
|
||||||
platform_file_handle Result = {};
|
platform_file_handle Result = {};
|
||||||
Result.Platform = (u64)File;
|
Result.Platform = (u64)File;
|
||||||
|
@ -557,7 +560,19 @@ inline void Win32_GetRelevantPaths(win32_state *State)
|
||||||
Win32_PlatformError("Path to executable is too long. Try running the game from another directory", true);
|
Win32_PlatformError("Path to executable is too long. Try running the game from another directory", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
s64 OnePastLastSlash = LastIndexOf(MakeStringFromCString(State->EXEPath), '\\') + 1;
|
string EXEPathString = MakeStringFromCString(State->EXEPath);
|
||||||
|
|
||||||
|
s64 OnePastLastSlash = LastIndexOf(EXEPathString, '\\') + 1;
|
||||||
|
s64 BuildIndex = LastIndexOf(EXEPathString, StrLit("build"));
|
||||||
|
|
||||||
|
if(BuildIndex == -1)
|
||||||
|
{
|
||||||
|
State->ContentsPath = MakeString((char *)EXEPathString.Data, OnePastLastSlash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
State->ContentsPath = MakeString((char *)EXEPathString.Data, BuildIndex);
|
||||||
|
}
|
||||||
|
|
||||||
string DLLName = StrLit("vn.dll");
|
string DLLName = StrLit("vn.dll");
|
||||||
Copy(State->DLLPath, State->EXEPath, OnePastLastSlash);
|
Copy(State->DLLPath, State->EXEPath, OnePastLastSlash);
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct win32_state
|
||||||
char EXEPath[512];
|
char EXEPath[512];
|
||||||
char DLLPath[512];
|
char DLLPath[512];
|
||||||
char TempDLLPath[512];
|
char TempDLLPath[512];
|
||||||
|
string ContentsPath;
|
||||||
|
|
||||||
platform_cursor Cursor;
|
platform_cursor Cursor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue