diff --git a/.gitignore b/.gitignore index e781ce5..d28431c 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,8 @@ bld/ *.exe *.out *.app + +# Custom +**/*.vcxproj +**/*.sln +!build/* \ No newline at end of file diff --git a/LemonUI.SHV.Example/Example.hpp b/LemonUI.SHV.Example/Example.hpp new file mode 100644 index 0000000..dd57947 --- /dev/null +++ b/LemonUI.SHV.Example/Example.hpp @@ -0,0 +1,86 @@ +#pragma once + +#include +#include +#include + +#include + +class Example +{ +private: + LemonUI::ScaledText* m_scaledText = nullptr; + LemonUI::Scaleform m_scaleform{ "mp_mm_card_freemode", { 0.122f, 0.3f }, { 0.28f, 0.6f } }; + + bool m_scaleformFocus = false; + +public: + void RenderScaledText() + { + if (this->m_scaledText == nullptr) + { + return; + } + LemonUI::Vec2 currentRes = LemonUI::GetScreenResolution(); + this->m_scaledText->SetPos({ currentRes.x / 2, currentRes.y - 60 }); + this->m_scaledText->Draw(); + } + + void DeleteCreateScaledText() + { + if (this->m_scaledText == nullptr) + { + this->m_scaledText = new LemonUI::ScaledText{ "Created with LemonUI.SHV by EntenKoeniq" }; + this->m_scaledText->SetScale(0.35f); + this->m_scaledText->SetDropShadow(true); + } + else + { + delete this->m_scaledText; + this->m_scaledText = nullptr; + } + } + + void RenderScaleform() + { + if (!this->m_scaleformFocus) + { + return; + } + + this->m_scaleform.StartFunction("SET_DATA_SLOT_EMPTY"); + this->m_scaleform.PushParam(0); + this->m_scaleform.FinishFunction(); + + this->m_scaleform.StartFunction("SET_DATA_SLOT"); + this->m_scaleform.PushParam(0); + this->m_scaleform.PushParam(std::string("16ms")); + this->m_scaleform.PushParam(std::string("EntenKoeniq")); + this->m_scaleform.PushParam(116); + this->m_scaleform.PushParam(0); + this->m_scaleform.PushParam(0); + this->m_scaleform.PushParam(std::string("")); + this->m_scaleform.PushParam(std::string("")); + this->m_scaleform.PushParam(2); + this->m_scaleform.PushParam(std::string("")); + this->m_scaleform.PushParam(std::string("")); + this->m_scaleform.PushParam(std::string(" ")); + this->m_scaleform.FinishFunction(); + + this->m_scaleform.StartFunction("SET_TITLE"); + this->m_scaleform.PushParam(std::string("Player list")); + this->m_scaleform.PushParam(std::string("1 players")); + this->m_scaleform.FinishFunction(); + + this->m_scaleform.CallFunction("DISPLAY_VIEW"); + + this->m_scaleform.Draw(); + } + + void FocusScaleform() + { + this->m_scaleformFocus = !this->m_scaleformFocus; + } +}; + +extern Example* _pGame = nullptr; \ No newline at end of file diff --git a/LemonUI.SHV.Example/dllmain.cpp b/LemonUI.SHV.Example/dllmain.cpp new file mode 100644 index 0000000..712e9eb --- /dev/null +++ b/LemonUI.SHV.Example/dllmain.cpp @@ -0,0 +1,74 @@ +#include "pch.h" +#include "Example.hpp" + +#include + +#include + +static void scriptKeyboardHandler(DWORD key, WORD repeats, BYTE scanCode, BOOL isExtended, BOOL isWithAlt, BOOL wasDownBefore, BOOL isUpNow) +{ + if (wasDownBefore == FALSE && isUpNow == FALSE) + { + if (key == VK_F3) + { + _pGame->DeleteCreateScaledText(); + } + else if (key == VK_F4) + { + _pGame->FocusScaleform(); + } + } +} + +static void scriptMainFunc() +{ + while (DLC::GET_IS_LOADING_SCREEN_ACTIVE()) + { + WAIT(0); + } + srand(GetTickCount()); + + _pGame = new Example(); + + LemonUI::ShowNotify("Welcome to ~y~LemonUI.SHV"); + LemonUI::ShowNotify("Use F3 to show/hide ScaledText and F4 to show/hide Scaleform"); + + while (true) + { + _pGame->RenderScaledText(); + _pGame->RenderScaleform(); + + WAIT(0); + } +} + +static void scriptInitialize(HMODULE hModule) +{ + scriptRegister(hModule, scriptMainFunc); + keyboardHandlerRegister(scriptKeyboardHandler); +} + +static void scriptUninitialize(HMODULE hModule) +{ + keyboardHandlerUnregister(scriptKeyboardHandler); + scriptUnregister(hModule); + + if (_pGame != nullptr) + { + delete _pGame; + } +} + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + scriptInitialize(hModule); + break; + case DLL_PROCESS_DETACH: + scriptUninitialize(hModule); + break; + } + return TRUE; +} \ No newline at end of file diff --git a/LemonUI.SHV.Example/pch.cpp b/LemonUI.SHV.Example/pch.cpp new file mode 100644 index 0000000..1730571 --- /dev/null +++ b/LemonUI.SHV.Example/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" \ No newline at end of file diff --git a/LemonUI.SHV.Example/pch.h b/LemonUI.SHV.Example/pch.h new file mode 100644 index 0000000..3e7c281 --- /dev/null +++ b/LemonUI.SHV.Example/pch.h @@ -0,0 +1,3 @@ +#pragma once + +#include \ No newline at end of file diff --git a/LemonUI.SHV/Alignment.cpp b/LemonUI.SHV/Alignment.cpp deleted file mode 100644 index fb85e61..0000000 --- a/LemonUI.SHV/Alignment.cpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace LemonUI -{ - -} diff --git a/LemonUI.SHV/Alignment.hpp b/LemonUI.SHV/Alignment.hpp index 7e1543b..d172a68 100644 --- a/LemonUI.SHV/Alignment.hpp +++ b/LemonUI.SHV/Alignment.hpp @@ -5,7 +5,7 @@ namespace LemonUI /// /// The alignment of the element to draw. /// - enum Alignment + enum class Alignment { /// /// Aligns the element to the Center. diff --git a/LemonUI.SHV/Font.hpp b/LemonUI.SHV/Font.hpp new file mode 100644 index 0000000..b16d52b --- /dev/null +++ b/LemonUI.SHV/Font.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace LemonUI +{ + /// + /// An enum representing the fonts available in game. + /// + enum class Font : unsigned char /* uint8_t */ + { + ChaletLondon = 0, + HouseScript = 1, + Monospace = 2, + CharletComprimeColonge = 4, + Pricedown = 7 + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/Helpers.cpp b/LemonUI.SHV/Helpers.cpp new file mode 100644 index 0000000..fdba5e3 --- /dev/null +++ b/LemonUI.SHV/Helpers.cpp @@ -0,0 +1,43 @@ +#include "pch.h" +#include "Helpers.hpp" + +namespace LemonUI +{ + void ShowNotify(const std::string& message) + { + HUD::BEGIN_TEXT_COMMAND_THEFEED_POST("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(message.c_str()); + HUD::END_TEXT_COMMAND_THEFEED_POST_TICKER(FALSE, FALSE); + } + + Vec2 GetScreenResolution() + { + int width, height; + GRAPHICS::GET_ACTIVE_SCREEN_RESOLUTION_(&width, &height); + return { static_cast(width), static_cast(height) }; + } + + float GetAspectRatio() + { + return GRAPHICS::GET_ASPECT_RATIO_(0); + } + + void ToRelative(const float& absoluteX, const float& absoluteY, float* relativeX, float* relativeY) + { + Vec2 currentRes = GetScreenResolution(); + float width = currentRes.y * GetAspectRatio(); + *relativeX = absoluteX / width; + *relativeY = absoluteY / currentRes.y; + } + + Vec2 GetRectCenter(const Vec2& pos, const Vec2& size) + { + return { pos.x + size.x / 2.0f, pos.y + size.y / 2.0f }; + } + + Vec2 GetScreenScale(const Vec2& vec) + { + Vec2 currentRes = GetScreenResolution(); + return { vec.x / currentRes.x, vec.y / currentRes.y }; + } +} \ No newline at end of file diff --git a/LemonUI.SHV/Helpers.hpp b/LemonUI.SHV/Helpers.hpp new file mode 100644 index 0000000..19a1f62 --- /dev/null +++ b/LemonUI.SHV/Helpers.hpp @@ -0,0 +1,14 @@ +#pragma once +#include "Vectors.hpp" + +#include + +namespace LemonUI +{ + extern void ShowNotify(const std::string& message); + extern Vec2 GetScreenResolution(); + extern float GetAspectRatio(); + extern void ToRelative(const float& absoluteX, const float& absoluteY, float* relativeX, float* relativeY); + extern Vec2 GetRectCenter(const Vec2& pos, const Vec2& size); + extern Vec2 GetScreenScale(const Vec2& vector); +} \ No newline at end of file diff --git a/LemonUI.SHV/IDrawable.hpp b/LemonUI.SHV/IDrawable.hpp index fe82483..245b735 100644 --- a/LemonUI.SHV/IDrawable.hpp +++ b/LemonUI.SHV/IDrawable.hpp @@ -11,6 +11,6 @@ namespace LemonUI /// /// Draws the item on the screen. /// - virtual void Draw() = 0; + virtual void Draw() const = 0; }; } diff --git a/LemonUI.SHV/IScaleform.hpp b/LemonUI.SHV/IScaleform.hpp new file mode 100644 index 0000000..51105bb --- /dev/null +++ b/LemonUI.SHV/IScaleform.hpp @@ -0,0 +1,17 @@ +#pragma once +#include "IDrawable.hpp" + +namespace LemonUI +{ + /// + /// Scaleforms are 2D Adobe Flash-like objects. + /// + class IScaleform : public IDrawable + { + public: + /// + /// Draws the Scaleform in full screen. + /// + virtual void DrawFullScreen() const = 0; + }; +} diff --git a/LemonUI.SHV/LemonUI.SHV.vcxproj b/LemonUI.SHV/LemonUI.SHV.vcxproj deleted file mode 100644 index b7b522c..0000000 --- a/LemonUI.SHV/LemonUI.SHV.vcxproj +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - 16.0 - Win32Proj - {094037e8-3b14-45c0-b03c-a0c591b2f3af} - LemonUISHV - 10.0 - - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - true - Unicode - - - - - - - - - - - - - - - true - $(SolutionDir)bin\$(Configuration)\ - ..\sdk\natives;..\sdk\scripthookv\inc;..\sdk\ikt;$(IncludePath) - ..\sdk\scripthookv\lib;$(LibraryPath) - - - false - $(SolutionDir)bin\$(Configuration)\ - ..\sdk\natives;..\sdk\scripthookv\inc;..\sdk\ikt;$(IncludePath) - ..\sdk\scripthookv\lib;$(LibraryPath) - - - - Level3 - true - _DEBUG;LEMONUISHV_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpp20 - stdc17 - - - Windows - true - false - - - powershell -Command "Set-Location ..\; .\sdk\download.ps1" - - - - - Level3 - true - true - true - NDEBUG;LEMONUISHV_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpp20 - stdc17 - - - Windows - true - true - true - false - - - powershell -Command "Set-Location ..\; .\sdk\download.ps1" - - - - - - \ No newline at end of file diff --git a/LemonUI.SHV/LemonUI.SHV.vcxproj.filters b/LemonUI.SHV/LemonUI.SHV.vcxproj.filters deleted file mode 100644 index 02a8978..0000000 --- a/LemonUI.SHV/LemonUI.SHV.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/LemonUI.SHV/ScaledText.cpp b/LemonUI.SHV/ScaledText.cpp new file mode 100644 index 0000000..e0131a7 --- /dev/null +++ b/LemonUI.SHV/ScaledText.cpp @@ -0,0 +1,59 @@ +#include "pch.h" +#include "ScaledText.hpp" + +#include "Helpers.hpp" + +namespace LemonUI +{ + ScaledText::ScaledText(const std::string& text) : m_text{ text.c_str() } + {} + + void ScaledText::Draw() const + { + if (this->m_text.empty()) + { + return; + } + + HUD::SET_TEXT_FONT(this->m_font); + HUD::SET_TEXT_SCALE(1.0f, this->m_scale); + HUD::SET_TEXT_COLOUR((int)(this->m_color.r * 255.0f), (int)(this->m_color.g * 255.0f), (int)(this->m_color.b * 255.0f), (int)(this->m_color.a * 255.0f)); + if (this->m_wrapping) + { + HUD::SET_TEXT_WRAP(this->m_pos.x, this->m_pos.x + this->m_wrapSize.x); + } + else + { + HUD::SET_TEXT_WRAP(0.0, 1.0); + } + if (this->m_align == Alignment::Center) + { + HUD::SET_TEXT_CENTRE(1); + } + else + { + HUD::SET_TEXT_CENTRE(0); + HUD::SET_TEXT_RIGHT_JUSTIFY(1); + } + if (this->m_dropShadow) + { + HUD::SET_TEXT_DROP_SHADOW(); + } + else + { + HUD::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0); + } + if (this->m_outline) + { + HUD::SET_TEXT_OUTLINE(); + } + + HUD::SET_TEXT_EDGE(1, 0, 0, 0, 205); + HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(this->m_text.c_str()); + + Vec2 relativePos{}; + ToRelative(this->m_pos.x, this->m_pos.y, &relativePos.x, &relativePos.y); + HUD::END_TEXT_COMMAND_DISPLAY_TEXT(relativePos.x, relativePos.y, 0); // 0 correct? + } +} \ No newline at end of file diff --git a/LemonUI.SHV/ScaledText.hpp b/LemonUI.SHV/ScaledText.hpp new file mode 100644 index 0000000..7ca2a02 --- /dev/null +++ b/LemonUI.SHV/ScaledText.hpp @@ -0,0 +1,45 @@ +#pragma once +#include "IDrawable.hpp" +#include "Alignment.hpp" +#include "Font.hpp" +#include "Vectors.hpp" +#include "Helpers.hpp" + +#include + +namespace LemonUI +{ + class ScaledText : public IDrawable + { + public: + ScaledText(const std::string& text); + ScaledText() = default; + + void SetPos(const Vec2& pos) { this->m_pos = pos; } + void SetText(const std::string& text) { this->m_text = const_cast(text.c_str()); } + void SetAlign(const Alignment& align) { this->m_align = align; } + void SetScale(const float& scale) { this->m_scale = scale; } + void SetColor(const Vec4& color) { this->m_color = color; } + void SetFont(const Font& font) { this->m_font = static_cast(font); } + void SetDropShadow(const bool& value) { this->m_dropShadow = value; } + void SetOutline(const bool& value) { this->m_outline = value; } + void SetWrapping(const bool& value, const Vec2& size) { this->m_wrapping = value; this->m_wrapSize = size; } + + void Draw() const override; + + private: + Vec2 m_pos = GetScreenResolution(); + std::string m_text = NULL; + + int m_font = 0; + Vec4 m_color{}; + float m_scale = 1.0f; + Alignment m_align = Alignment::Center; + + bool m_dropShadow = false; + bool m_outline = false; + + bool m_wrapping = false; + Vec2 m_wrapSize{}; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/Scaleform.cpp b/LemonUI.SHV/Scaleform.cpp new file mode 100644 index 0000000..496e613 --- /dev/null +++ b/LemonUI.SHV/Scaleform.cpp @@ -0,0 +1,76 @@ +#include "pch.h" +#include "Scaleform.hpp" + +#include "Helpers.hpp" + +namespace LemonUI +{ + Scaleform::Scaleform(const std::string& name, const Vec2& pos, const Vec2& size) + : m_handle{ GRAPHICS::REQUEST_SCALEFORM_MOVIE(const_cast(name.c_str())) }, m_pos{ pos }, m_size{ size } + {} + Scaleform::Scaleform(const std::string& name) : m_handle{ GRAPHICS::REQUEST_SCALEFORM_MOVIE(const_cast(name.c_str())) } + {} + Scaleform::~Scaleform() + { + if (this->IsLoaded()) + { + GRAPHICS::SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED(&this->m_handle); + } + } + + void Scaleform::Set(const Vec2& pos, const Vec2& size) + { + this->m_pos = pos; + this->m_size = size; + } + + bool Scaleform::IsValid() const + { + return this->m_handle != 0; + } + bool Scaleform::IsLoaded() const + { + return GRAPHICS::HAS_SCALEFORM_MOVIE_LOADED(this->m_handle); + } + + void Scaleform::CallFunction(const std::string& name) const + { + GRAPHICS::CALL_SCALEFORM_MOVIE_METHOD(this->m_handle, name.c_str()); + } + + void Scaleform::StartFunction(const std::string& name) const + { + GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(this->m_handle, name.c_str()); + } + + void Scaleform::PushParam(const std::string& param) const + { + GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(param.c_str()); + } + void Scaleform::PushParam(const int& param) const + { + GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(param); + } + void Scaleform::PushParam(const float& param) const + { + GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_FLOAT(param); + } + void Scaleform::PushParam(const bool& param) const + { + GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_BOOL(param); + } + + void Scaleform::FinishFunction() const + { + GRAPHICS::END_SCALEFORM_MOVIE_METHOD(); + } + + void Scaleform::DrawFullScreen() const + { + GRAPHICS::DRAW_SCALEFORM_MOVIE_FULLSCREEN(this->m_handle, 255, 255, 255, 255, 0); + } + void Scaleform::Draw() const + { + GRAPHICS::DRAW_SCALEFORM_MOVIE(this->m_handle, this->m_pos.x, this->m_pos.y, this->m_size.x, this->m_size.y, 255, 255, 255, 255, 0); + } +} \ No newline at end of file diff --git a/LemonUI.SHV/Scaleform.hpp b/LemonUI.SHV/Scaleform.hpp new file mode 100644 index 0000000..9b346f5 --- /dev/null +++ b/LemonUI.SHV/Scaleform.hpp @@ -0,0 +1,41 @@ +#pragma once +#include "IScaleform.hpp" +#include "Vectors.hpp" + +#include + +namespace LemonUI +{ + class Scaleform : public IScaleform + { + public: + Scaleform(const std::string& name, const Vec2& pos, const Vec2& size); + Scaleform(const std::string& name); + ~Scaleform(); + + void Set(const Vec2& pos, const Vec2& size); + + bool IsValid() const; + bool IsLoaded() const; + + void CallFunction(const std::string& name) const; + + void StartFunction(const std::string& name) const; + + void PushParam(const std::string& param) const; + void PushParam(const int& param) const; + void PushParam(const float& param) const; + void PushParam(const bool& param) const; + + void FinishFunction() const; + + void DrawFullScreen() const override; + void Draw() const override; + + private: + int m_handle = 0; + + Vec2 m_pos{}; + Vec2 m_size{}; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/Sound.cpp b/LemonUI.SHV/Sound.cpp index f01576b..36de139 100644 --- a/LemonUI.SHV/Sound.cpp +++ b/LemonUI.SHV/Sound.cpp @@ -1,39 +1,34 @@ -#include -#include +#include "pch.h" #include "Sound.hpp" namespace LemonUI { - Sound::Sound(std::string set, std::string file) - { - this->set = set; - this->file = file; - } + Sound::Sound(std::string set, std::string file) : set{set}, file{file} + {} - std::string Sound::GetSet() + std::string Sound::GetSet() const { return this->set; } - void Sound::SetSet(std::string set) + void Sound::SetSet(const std::string& file) { this->set = set; } - std::string Sound::GetFile() + std::string Sound::GetFile() const { return this->file; } - void Sound::SetFile(std::string file) + void Sound::SetFile(const std::string& file) { this->file = file; } void Sound::PlayFrontend() { - AUDIO::PLAY_SOUND_FRONTEND(-1, file.c_str(), set.c_str(), false); - int id = AUDIO::GET_SOUND_ID(); - AUDIO::RELEASE_SOUND_ID(id); + AUDIO::PLAY_SOUND_FRONTEND(-1, file.c_str(), set.c_str(), FALSE); + AUDIO::RELEASE_SOUND_ID(AUDIO::GET_SOUND_ID()); } } diff --git a/LemonUI.SHV/Sound.hpp b/LemonUI.SHV/Sound.hpp index 8268f66..3662b8d 100644 --- a/LemonUI.SHV/Sound.hpp +++ b/LemonUI.SHV/Sound.hpp @@ -12,10 +12,10 @@ namespace LemonUI public: Sound(std::string set, std::string file); - std::string GetSet(); - void SetSet(std::string); - std::string GetFile(); - void SetFile(std::string); + std::string GetSet() const; + void SetSet(const std::string& file); + std::string GetFile() const; + void SetFile(const std::string& file); void PlayFrontend(); }; diff --git a/LemonUI.SHV/Vectors.hpp b/LemonUI.SHV/Vectors.hpp new file mode 100644 index 0000000..776c888 --- /dev/null +++ b/LemonUI.SHV/Vectors.hpp @@ -0,0 +1,48 @@ +#pragma once + +namespace LemonUI +{ + /// + /// Default value = 1.0f + /// + struct Vec2 + { + float x = 1.0f, y = 1.0f; + + Vec2(float x, float y) + { + this->x = x; + this->y = y; + } + Vec2(float value) + { + this->x = value; + this->y = value; + } + Vec2() {} + }; + + /// + /// Default value = 1.0f + /// + struct Vec4 + { + float r = 1.0f, g = 1.0f, b = 1.0f, a = 1.0f; + + Vec4(float r, float g, float b, float a) + { + this->r = r; + this->g = g; + this->b = b; + this->a = a; + } + Vec4(float value) + { + this->r = value; + this->g = value; + this->b = value; + this->a = value; + } + Vec4() {} + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/pch.cpp b/LemonUI.SHV/pch.cpp new file mode 100644 index 0000000..1d9f38c --- /dev/null +++ b/LemonUI.SHV/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/LemonUI.SHV/pch.h b/LemonUI.SHV/pch.h new file mode 100644 index 0000000..01033d4 --- /dev/null +++ b/LemonUI.SHV/pch.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +#include \ No newline at end of file diff --git a/LemonUI_CPP.sln b/LemonUI_CPP.sln deleted file mode 100644 index d9f8325..0000000 --- a/LemonUI_CPP.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32210.308 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LemonUI.SHV", "LemonUI.SHV\LemonUI.SHV.vcxproj", "{094037E8-3B14-45C0-B03C-A0C591B2F3AF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {094037E8-3B14-45C0-B03C-A0C591B2F3AF}.Debug|x64.ActiveCfg = Debug|x64 - {094037E8-3B14-45C0-B03C-A0C591B2F3AF}.Debug|x64.Build.0 = Debug|x64 - {094037E8-3B14-45C0-B03C-A0C591B2F3AF}.Release|x64.ActiveCfg = Release|x64 - {094037E8-3B14-45C0-B03C-A0C591B2F3AF}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2A114F7F-5AA6-437F-A45A-66975C1C0F6B} - EndGlobalSection -EndGlobal diff --git a/build/GenVS2019.bat b/build/GenVS2019.bat new file mode 100644 index 0000000..7f69a10 --- /dev/null +++ b/build/GenVS2019.bat @@ -0,0 +1,5 @@ +@echo off +pushd %~dp0\..\ +call build\premake5.exe vs2019 +popd +PAUSE \ No newline at end of file diff --git a/build/GenVS2022.bat b/build/GenVS2022.bat new file mode 100644 index 0000000..f8ac704 --- /dev/null +++ b/build/GenVS2022.bat @@ -0,0 +1,5 @@ +@echo off +pushd %~dp0\..\ +call build\premake5.exe vs2022 +popd +PAUSE \ No newline at end of file diff --git a/build/premake5.exe b/build/premake5.exe new file mode 100644 index 0000000..c73da1f Binary files /dev/null and b/build/premake5.exe differ diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..9e52ce7 --- /dev/null +++ b/premake5.lua @@ -0,0 +1,135 @@ +workspace "LemonUI_CPP" + architecture "x64" + startproject "LemonUI.SHV" + + configurations { "Debug", "Release" } + + flags + { + "MultiProcessorCompile" + } + +-- Include directories +IncludeDir = {} +IncludeDir["scripthookv"] = "sdk/scripthookv/inc" +IncludeDir["natives"] = "sdk/natives" +IncludeDir["ikt"] = "sdk/ikt" +IncludeDir["lemonui"] = "LemonUI.SHV/" + +-- Libraries +LibrariesDir = {} +LibrariesDir["scripthookv"] = "sdk/scripthookv/lib" +LibrariesDir["lemonui"] = "bin/Debug/LemonUI.SHV" + +project "LemonUI.SHV" + location "LemonUI.SHV" + kind "StaticLib" + language "C++" + cppdialect "C++17" + staticruntime "off" + + targetdir("bin/%{cfg.buildcfg}/%{prj.name}") + objdir("bin-int/%{cfg.buildcfg}/%{prj.name}") + + pchheader "pch.h" + pchsource "LemonUI.SHV/pch.cpp" + + prebuildcommands + { + "powershell -Command \"Set-Location ..\\; .\\sdk\\download.ps1\"" + } + + files + { + "LemonUI.SHV/**.hpp", + "LemonUI.SHV/**.cpp" + } + + includedirs + { + "%{IncludeDir.scripthookv}", + "%{IncludeDir.natives}", + "%{IncludeDir.ikt}" + } + + libdirs + { + "%{LibrariesDir.scripthookv}" + } + + links + { + "ScriptHookV" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + runtime "Debug" + symbols "on" + + defines + { + "_DEBUG" + } + + filter "configurations:Release" + runtime "Release" + symbols "off" + +project "LemonUI.SHV.Example" + location "LemonUI.SHV.Example" + kind "SharedLib" + targetextension ".asi" + language "C++" + cppdialect "C++17" + staticruntime "off" + + targetdir("bin/%{cfg.buildcfg}/%{prj.name}") + objdir("bin-int/%{cfg.buildcfg}/%{prj.name}") + + pchheader "pch.h" + pchsource "LemonUI.SHV.Example/pch.cpp" + + files + { + "LemonUI.SHV.Example/**.hpp", + "LemonUI.SHV.Example/**.cpp" + } + + includedirs + { + "%{IncludeDir.scripthookv}", + "%{IncludeDir.natives}", + "%{IncludeDir.ikt}", + "%{IncludeDir.lemonui}" + } + + libdirs + { + "%{LibrariesDir.scripthookv}", + "%{LibrariesDir.lemonui}" + } + + links + { + "ScriptHookV.lib", + "LemonUI.SHV.lib" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + runtime "Debug" + symbols "on" + + defines + { + "_DEBUG" + } + + filter "configurations:Release" + runtime "Release" + symbols "off" \ No newline at end of file