Skip to content

Commit

Permalink
add copy func
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnTW committed Oct 28, 2024
1 parent e117dd1 commit 1646400
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
18 changes: 17 additions & 1 deletion M2TWEOP Code/M2TWEOP library/imgui/sol_ImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,16 @@ namespace sol_ImGui
void SetMouseCursor(int cursor_type) { ImGui::SetMouseCursor(static_cast<ImGuiMouseCursor>(cursor_type)); }
void SetNextFrameWantCaptureMouse(bool want_capture_mouse_value) { ImGui::SetNextFrameWantCaptureMouse(want_capture_mouse_value); }

ImFont* AddFontFromFileTTF(ImFontAtlas* fontAtlas, const char* filename, float size_pixels)
{
return fontAtlas->AddFontFromFileTTF(filename, size_pixels);
}

ImFont* AddFontFromFileTTF(ImFontAtlas* fontAtlas, const char* filename, float size_pixels, const ImFontConfig* font_cfg_template)
{
return fontAtlas->AddFontFromFileTTF(filename, size_pixels, font_cfg_template);
}

ImFont* AddFontFromFileTTF(ImFontAtlas* fontAtlas, const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
{
return fontAtlas->AddFontFromFileTTF(filename, size_pixels, font_cfg_template, glyph_ranges);
Expand Down Expand Up @@ -5666,11 +5676,17 @@ namespace sol_ImGui
@function FontAtlas:AddFontFromFileTTF
@tparam string filename
@tparam float sizePixels
@tparam void fontConfig optional
@tparam void glyphRanges optional
@treturn ImFont font
@usage
FontAtlas:AddFontFromFileTTF();
*/
FontAtlas.set_function("AddFontFromFileTTF", &AddFontFromFileTTF);
FontAtlas.set_function("AddFontFromFileTTF", sol::overload(
sol::resolve<ImFont*(ImFontAtlas*, const char*, float)>(AddFontFromFileTTF),
sol::resolve<ImFont*(ImFontAtlas*, const char*, float, const ImFontConfig*)>(AddFontFromFileTTF),
sol::resolve<ImFont*(ImFontAtlas*, const char*, float, const ImFontConfig*, const ImWchar*)>(AddFontFromFileTTF)
));

/***
Access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags).
Expand Down
11 changes: 11 additions & 0 deletions M2TWEOP Code/M2TWEOP library/luaPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ sol::state* luaPlugin::init(std::string& luaFilePath, std::string& modPath)
@tfield restartLua restartLua
@tfield toggleDeveloperMode toggleDeveloperMode
@tfield saveGame saveGame
@tfield copyFile copyFile
@tfield getGameVersion getGameVersion
@tfield setPerfectSpy setPerfectSpy
@tfield getLocalFactionID getLocalFactionID
Expand Down Expand Up @@ -336,6 +337,16 @@ sol::state* luaPlugin::init(std::string& luaFilePath, std::string& modPath)
*/
tables.M2TWEOP.set_function("saveGame", &gameHelpers::saveGame);

/***
Copy a file.
@function M2TWEOP.copyFile
@tparam string from
@tparam string to
@usage
M2TWEOP.copyFile(M2TWEOP.getModPath().."/saves/newsave.sav", M2TWEOP.getModPath().."/backupSaves/newsave.sav");
*/
tables.M2TWEOP.set_function("copyFile", &gameHelpers::copyFileLua);

/***
Function to get the game version.
@function M2TWEOP.getGameVersion
Expand Down
11 changes: 11 additions & 0 deletions M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,17 @@ namespace gameHelpers
return path.substr(pos + 1, path.length() - pos);
}

void copyFileLua(const std::string& file, const std::string& to)
{
//CopyFileA(file.c_str(), to.c_str(), FALSE);
if (!std::filesystem::exists(file))
{
logStringGame("M2TWEOP.copyFile: File not found: " + file);
return;
}
std::filesystem::copy(file, to, std::filesystem::copy_options::overwrite_existing);
}

void setEquipmentCosts(const int equipType, const int cost)
{
struct equipmentCosts
Expand Down
1 change: 1 addition & 0 deletions M2TWEOP Code/M2TWEOP library/types/gameHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ namespace gameHelpers
std::string getModPath();
std::string getLuaPath();
std::string getModFolderName();
void copyFileLua(const std::string& file, const std::string& to);
std::string getModString(const std::string& path);
int getGameVersion();
void generateSprite(const std::string& model);
Expand Down
4 changes: 3 additions & 1 deletion M2TWEOP DataFiles/eopData/eopScripts/LuaImGuiDocs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,10 @@ ImFontAtlas = {
--- Access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags).
---@param filename string
---@param sizePixels number
---@param fontConfig void? optional
---@param glyphRanges void? optional
---@return ImFont font
function ImFontAtlas:AddFontFromFileTTF(filename, sizePixels) end
function ImFontAtlas:AddFontFromFileTTF(filename, sizePixels, fontConfig, glyphRanges) end

---Basic ImDrawList table
---@class ImDrawList
Expand Down

0 comments on commit 1646400

Please sign in to comment.