diff --git a/.gitignore b/.gitignore index e781ce5..c732155 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/src/Example.hpp b/LemonUI.SHV.Example/src/Example.hpp new file mode 100644 index 0000000..fe07ea0 --- /dev/null +++ b/LemonUI.SHV.Example/src/Example.hpp @@ -0,0 +1,105 @@ +#pragma once + +#include +#include +#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 } }; + LemonUI::NativeMenu m_menu{}; + + bool m_scaleformFocus = false; + +public: + void InitMenu() + { + LemonUI::Vec2 currentRes = LemonUI::GetScreenResolution(); + this->m_menu.SetPosition({ currentRes.x / 2, currentRes.y / 2 }); + this->m_menu.AddItem("The first item"); + this->m_menu.AddItem("The second item"); + this->m_menu.AddItem("The last item"); + this->m_menu.AddItem("Go back"); + } + void RenderMenu() + { + this->m_menu.Render(); + } + + 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->SetAlign(LemonUI::Alignment::Center); + this->m_scaledText->SetColor({ 255.0f, 187.0f, 0.0f, 255.0f }); + 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/src/dllmain.cpp b/LemonUI.SHV.Example/src/dllmain.cpp new file mode 100644 index 0000000..4ea73e1 --- /dev/null +++ b/LemonUI.SHV.Example/src/dllmain.cpp @@ -0,0 +1,76 @@ +#include "pch.hpp" +#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(); + _pGame->InitMenu(); + + 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(); + _pGame->RenderMenu(); + + 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/src/pch.cpp b/LemonUI.SHV.Example/src/pch.cpp new file mode 100644 index 0000000..7f3196a --- /dev/null +++ b/LemonUI.SHV.Example/src/pch.cpp @@ -0,0 +1 @@ +#include "pch.hpp" \ No newline at end of file diff --git a/LemonUI.SHV.Example/src/pch.hpp b/LemonUI.SHV.Example/src/pch.hpp new file mode 100644 index 0000000..3e7c281 --- /dev/null +++ b/LemonUI.SHV.Example/src/pch.hpp @@ -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/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/Sound.cpp b/LemonUI.SHV/Sound.cpp deleted file mode 100644 index f01576b..0000000 --- a/LemonUI.SHV/Sound.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include "Sound.hpp" - -namespace LemonUI -{ - Sound::Sound(std::string set, std::string file) - { - this->set = set; - this->file = file; - } - - std::string Sound::GetSet() - { - return this->set; - } - - void Sound::SetSet(std::string set) - { - this->set = set; - } - - std::string Sound::GetFile() - { - return this->file; - } - - void Sound::SetFile(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); - } -} diff --git a/LemonUI.SHV/Alignment.hpp b/LemonUI.SHV/src/Elements/Alignment.hpp similarity index 89% rename from LemonUI.SHV/Alignment.hpp rename to LemonUI.SHV/src/Elements/Alignment.hpp index 7e1543b..9366ad5 100644 --- a/LemonUI.SHV/Alignment.hpp +++ b/LemonUI.SHV/src/Elements/Alignment.hpp @@ -5,7 +5,7 @@ namespace LemonUI /// /// The alignment of the element to draw. /// - enum Alignment + enum class Alignment : UINT8 { /// /// Aligns the element to the Center. @@ -18,6 +18,6 @@ namespace LemonUI /// /// Aligns the element to the RIght. /// - Right = 2, + Right = 2 }; } diff --git a/LemonUI.SHV/src/Elements/Font.hpp b/LemonUI.SHV/src/Elements/Font.hpp new file mode 100644 index 0000000..7029d2d --- /dev/null +++ b/LemonUI.SHV/src/Elements/Font.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace LemonUI +{ + /// + /// An enum representing the fonts available in game. + /// + enum class Font : UINT8 + { + ChaletLondon = 0, + HouseScript = 1, + Monospace = 2, + CharletComprimeColonge = 4, + Pricedown = 7 + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Elements/ScaledText.cpp b/LemonUI.SHV/src/Elements/ScaledText.cpp new file mode 100644 index 0000000..0d6345d --- /dev/null +++ b/LemonUI.SHV/src/Elements/ScaledText.cpp @@ -0,0 +1,66 @@ +#include "pch.hpp" +#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; + } + + Vec2 relativePos{}; + ToRelative(this->m_pos.x, this->m_pos.y, &relativePos.x, &relativePos.y); + + HUD::SET_TEXT_FONT(this->m_font); + HUD::SET_TEXT_SCALE(1.0f, this->m_scale); + HUD::SET_TEXT_COLOUR((int)m_color.r, (int)m_color.g, (int)m_color.b, (int)m_color.a); + if (this->m_wrapping) + { + switch (this->m_align) + { + case Alignment::Left: + HUD::SET_TEXT_WRAP(relativePos.x, relativePos.x + this->m_wrapSize.x); + break; + case Alignment::Center: + HUD::SET_TEXT_WRAP(relativePos.x - (this->m_wrapSize.x * 0.5f), relativePos.x + (this->m_wrapSize.x * 0.5f)); + break; + case Alignment::Right: + HUD::SET_TEXT_WRAP(relativePos.x - this->m_wrapSize.x, relativePos.x); + break; + } + } + else if (this->m_align == Alignment::Right) + { + HUD::SET_TEXT_WRAP(0.0f, relativePos.x); + } + HUD::SET_TEXT_JUSTIFICATION((int)this->m_align); + + if (this->m_dropShadow) + { + HUD::SET_TEXT_DROP_SHADOW(); + } + + if (this->m_outline) + { + HUD::SET_TEXT_OUTLINE(); + } + + HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(this->m_text.c_str()); + + HUD::END_TEXT_COMMAND_DISPLAY_TEXT(relativePos.x, relativePos.y, 0); // 0 correct? + + // TODO + if (this->m_background) + { + float textLength = (float)this->m_text.size() / 100; + GRAPHICS::DRAW_RECT(relativePos.x, relativePos.y, textLength, 0.037f, (int)m_bgColor.r, (int)m_bgColor.g, (int)m_bgColor.b, (int)m_bgColor.a, 0); + } + } +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Elements/ScaledText.hpp b/LemonUI.SHV/src/Elements/ScaledText.hpp new file mode 100644 index 0000000..77f813d --- /dev/null +++ b/LemonUI.SHV/src/Elements/ScaledText.hpp @@ -0,0 +1,54 @@ +#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 = text; } + 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 = (int)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 SetBackground(const bool& value) { this->m_background = value; } + void SetBackgroundPos(const Vec2& pos) { this->m_bgPos = pos; } + void SetBackgroundSize(const Vec2& size) { this->m_bgSize = size; } + void SetBackgroundColor(const Vec4& color) { this->m_bgColor = color; } + + void Draw() const override; + + private: + Vec2 m_pos = GetScreenResolution(); + std::string m_text = ""; + + int m_font = 0; + Vec4 m_color{ 255.0f, 255.0f, 255.0f, 255.0f }; + float m_scale = 1.0f; + Alignment m_align = Alignment::Left; + + bool m_dropShadow = false; + bool m_outline = false; + + bool m_wrapping = false; + Vec2 m_wrapSize{}; + + bool m_background = false; + Vec2 m_bgPos{}; + Vec2 m_bgSize{}; + Vec4 m_bgColor{ 75.0f }; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Elements/Texture.cpp b/LemonUI.SHV/src/Elements/Texture.cpp new file mode 100644 index 0000000..1eafc28 --- /dev/null +++ b/LemonUI.SHV/src/Elements/Texture.cpp @@ -0,0 +1,53 @@ +#include "pch.hpp" +#include "Texture.hpp" +#include "Helpers.hpp" + +namespace LemonUI +{ + Texture::Texture(const std::string& dict, const std::string& name) : m_dict{ dict }, m_name{ name } + {} + + Vec2 Texture::GetSize() const + { + Vector3 result = GRAPHICS::GET_TEXTURE_RESOLUTION(this->m_dict.c_str(), this->m_name.c_str()); + return { result.x, result.y }; + } + + void Texture::Set(const std::string& dict, const std::string& name) + { + this->m_dict = dict; + this->m_name = name; + + this->EnsureLoaded(); + } + + void Texture::EnsureLoaded() const + { + if (!GRAPHICS::HAS_STREAMED_TEXTURE_DICT_LOADED(this->m_dict.c_str())) + { + GRAPHICS::REQUEST_STREAMED_TEXTURE_DICT(this->m_dict.c_str(), 1); + } + } + + void Texture::Render(const Vec2& pos) const + { + this->Render(pos, this->GetSize(), 0.0f, { 255.0f }); + } + void Texture::Render(const Vec2& pos, const Vec2& size) const + { + this->Render(pos, size, 0.0f, { 255.0f }); + } + void Texture::Render(const Vec2& pos, const Vec2& size, const float& heading) const + { + this->Render(pos, size, heading, { 255.0f }); + } + void Texture::Render(const Vec2& pos, const Vec2& size, const float& heading, const Vec4& color) const + { + this->EnsureLoaded(); + + Vec2 spos = GetScreenScale(GetRectCenter(pos, size)); + Vec2 ssize = GetScreenScale(size); + + GRAPHICS::DRAW_SPRITE(this->m_dict.c_str(), this->m_name.c_str(), spos.x, spos.y, ssize.x, ssize.y, heading, (int)(color.r * 255.0f), (int)(color.g * 255.0f), (int)(color.b * 255.0f), (int)(color.a * 255.0f), 0); // 0 correct? + } +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Elements/Texture.hpp b/LemonUI.SHV/src/Elements/Texture.hpp new file mode 100644 index 0000000..b42e538 --- /dev/null +++ b/LemonUI.SHV/src/Elements/Texture.hpp @@ -0,0 +1,29 @@ +#pragma once +#include "Vectors.hpp" + +#include + +namespace LemonUI +{ + class Texture + { + public: + Texture(const std::string& dict, const std::string& name); + Texture() = default; + + Vec2 GetSize() const; + + void Set(const std::string& dict, const std::string& name); + + void EnsureLoaded() const; + + void Render(const Vec2& pos) const; + void Render(const Vec2& pos, const Vec2& size) const; + void Render(const Vec2& pos, const Vec2& size, const float& heading) const; + void Render(const Vec2& pos, const Vec2& size, const float& heading, const Vec4& color) const; + + private: + std::string m_dict = ""; + std::string m_name = ""; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/src/GameControl.hpp b/LemonUI.SHV/src/GameControl.hpp new file mode 100644 index 0000000..92825df --- /dev/null +++ b/LemonUI.SHV/src/GameControl.hpp @@ -0,0 +1,343 @@ +#pragma once + +enum class GameControl : int +{ + GC_NextCamera, + GC_LookLeftRight, + GC_LookUpDown, + GC_LookUpOnly, + GC_LookDownOnly, + GC_LookLeftOnly, + GC_LookRightOnly, + GC_CinematicSlowMo, + GC_FlyUpDown, + GC_FlyLeftRight, + GC_ScriptedFlyZUp, + GC_ScriptedFlyZDown, + GC_WeaponWheelUpDown, + GC_WeaponWheelLeftRight, + GC_WeaponWheelNext, + GC_WeaponWheelPrev, + GC_SelectNextWeapon, + GC_SelectPrevWeapon, + GC_SkipCutscene, + GC_CharacterWheel, + GC_MultiplayerInfo, + GC_Sprint, + GC_Jump, + GC_Enter, + GC_Attack, + GC_Aim, + GC_LookBehind, + GC_Phone, + GC_SpecialAbility, + GC_SpecialAbilitySecondary, + GC_MoveLeftRight, + GC_MoveUpDown, + GC_MoveUpOnly, + GC_MoveDownOnly, + GC_MoveLeftOnly, + GC_MoveRightOnly, + GC_Duck, + GC_SelectWeapon, + GC_pickup, + GC_SniperZoom, + GC_SniperZoomInOnly, + GC_SniperZoomOutOnly, + GC_SniperZoomInSecondary, + GC_SniperZoomOutSecondary, + GC_Cover, + GC_Reload, + GC_Talk, + GC_Detonate, + GC_HUDSpecial, + GC_Arrest, + GC_AccurateAim, + GC_Context, + GC_ContextSecondary, + GC_WeaponSpecial, + GC_WeaponSpecial2, + GC_Dive, + GC_DropWeapon, + GC_DropAmmo, + GC_ThrowGrenade, + GC_VehicleMoveLeftRight, + GC_VehicleMoveUpDown, + GC_VehicleMoveUpOnly, + GC_VehicleMoveDownOnly, + GC_VehicleMoveLeftOnly, + GC_VehicleMoveRightOnly, + GC_VehicleSpecial, + GC_VehicleGunLeftRight, + GC_VehicleGunUpDown, + GC_VehicleAim, + GC_VehicleAttack, + GC_VehicleAttack2, + GC_VehicleAccelerate, + GC_VehicleBrake, + GC_VehicleDuck, + GC_VehicleHeadlight, + GC_VehicleExit, + GC_VehicleHandbrake, + GC_VehicleHotwireLeft, + GC_VehicleHotwireRight, + GC_VehicleLookBehind, + GC_VehicleCinCam, + GC_VehicleNextRadio, + GC_VehiclePrevRadio, + GC_VehicleNextRadioTrack, + GC_VehiclePrevRadioTrack, + GC_VehicleRadioWheel, + GC_VehicleHorn, + GC_VehicleFlyThrottleUp, + GC_VehicleFlyThrottleDown, + GC_VehicleFlyYawLeft, + GC_VehicleFlyYawRight, + GC_VehiclePassengerAim, + GC_VehiclePassengerAttack, + GC_VehicleSpecialAbilityFranklin, + GC_VehicleStuntUpDown, + GC_VehicleCinematicUpDown, + GC_VehicleCinematicUpOnly, + GC_VehicleCinematicDownOnly, + GC_VehicleCinematicLeftRight, + GC_VehicleSelectNextWeapon, + GC_VehicleSelectPrevWeapon, + GC_VehicleRoof, + GC_VehicleJump, + GC_VehicleGrapplingHook, + GC_VehicleShuffle, + GC_VehicleDropProjectile, + GC_VehicleMouseControlOverride, + GC_VehicleFlyRollLeftRight, + GC_VehicleFlyRollLeftOnly, + GC_VehicleFlyRollRightOnly, + GC_VehicleFlyPitchUpDown, + GC_VehicleFlyPitchUpOnly, + GC_VehicleFlyPitchDownOnly, + GC_VehicleFlyUnderCarriage, + GC_VehicleFlyAttack, + GC_VehicleFlySelectNextWeapon, + GC_VehicleFlySelectPrevWeapon, + GC_VehicleFlySelectTargetLeft, + GC_VehicleFlySelectTargetRight, + GC_VehicleFlyVerticalFlightMode, + GC_VehicleFlyDuck, + GC_VehicleFlyAttackCamera, + GC_VehicleFlyMouseControlOverride, + GC_VehicleSubTurnLeftRight, + GC_VehicleSubTurnLeftOnly, + GC_VehicleSubTurnRightOnly, + GC_VehicleSubPitchUpDown, + GC_VehicleSubPitchUpOnly, + GC_VehicleSubPitchDownOnly, + GC_VehicleSubThrottleUp, + GC_VehicleSubThrottleDown, + GC_VehicleSubAscend, + GC_VehicleSubDescend, + GC_VehicleSubTurnHardLeft, + GC_VehicleSubTurnHardRight, + GC_VehicleSubMouseControlOverride, + GC_VehiclePushbikePedal, + GC_VehiclePushbikeSprint, + GC_VehiclePushbikeFrontBrake, + GC_VehiclePushbikeRearBrake, + GC_MeleeAttackLight, + GC_MeleeAttackHeavy, + GC_MeleeAttackAlternate, + GC_MeleeBlock, + GC_ParachuteDeploy, + GC_ParachuteDetach, + GC_ParachuteTurnLeftRight, + GC_ParachuteTurnLeftOnly, + GC_ParachuteTurnRightOnly, + GC_ParachutePitchUpDown, + GC_ParachutePitchUpOnly, + GC_ParachutePitchDownOnly, + GC_ParachuteBrakeLeft, + GC_ParachuteBrakeRight, + GC_ParachuteSmoke, + GC_ParachutePrecisionLanding, + GC_Map, + GC_SelectWeaponUnarmed, + GC_SelectWeaponMelee, + GC_SelectWeaponHandgun, + GC_SelectWeaponShotgun, + GC_SelectWeaponSmg, + GC_SelectWeaponAutoRifle, + GC_SelectWeaponSniper, + GC_SelectWeaponHeavy, + GC_SelectWeaponSpecial, + GC_SelectCharacterMichael, + GC_SelectCharacterFranklin, + GC_SelectCharacterTrevor, + GC_SelectCharacterMultiplayer, + GC_SaveReplayClip, + GC_SpecialAbilityPC, + GC_PhoneUp, + GC_PhoneDown, + GC_PhoneLeft, + GC_PhoneRight, + GC_PhoneSelect, + GC_PhoneCancel, + GC_PhoneOption, + GC_PhoneExtraOption, + GC_PhoneScrollForward, + GC_PhoneScrollBackward, + GC_PhoneCameraFocusLock, + GC_PhoneCameraGrid, + GC_PhoneCameraSelfie, + GC_PhoneCameraDOF, + GC_PhoneCameraExpression, + GC_FrontendDown, + GC_FrontendUp, + GC_FrontendLeft, + GC_FrontendRight, + GC_FrontendRdown, + GC_FrontendRup, + GC_FrontendRleft, + GC_FrontendRright, + GC_FrontendAxisX, + GC_FrontendAxisY, + GC_FrontendRightAxisX, + GC_FrontendRightAxisY, + GC_FrontendPause, + GC_FrontendPauseAlternate, + GC_FrontendAccept, + GC_FrontendCancel, + GC_FrontendX, + GC_FrontendY, + GC_FrontendLb, + GC_FrontendRb, + GC_FrontendLt, + GC_FrontendRt, + GC_FrontendLs, + GC_FrontendRs, + GC_FrontendLeaderboard, + GC_FrontendSocialClub, + GC_FrontendSocialClubSecondary, + GC_FrontendDelete, + GC_FrontendEndscreenAccept, + GC_FrontendEndscreenExpand, + GC_FrontendSelect, + GC_ScriptLeftAxisX, + GC_ScriptLeftAxisY, + GC_ScriptRightAxisX, + GC_ScriptRightAxisY, + GC_ScriptRUp, + GC_ScriptRDown, + GC_ScriptRLeft, + GC_ScriptRRight, + GC_ScriptLB, + GC_ScriptRB, + GC_ScriptLT, + GC_ScriptRT, + GC_ScriptLS, + GC_ScriptRS, + GC_ScriptPadUp, + GC_ScriptPadDown, + GC_ScriptPadLeft, + GC_ScriptPadRight, + GC_ScriptSelect, + GC_CursorAccept, + GC_CursorCancel, + GC_CursorX, + GC_CursorY, + GC_CursorScrollUp, + GC_CursorScrollDown, + GC_EnterCheatCode, + GC_InteractionMenu, + GC_MpTextChatAll, + GC_MpTextChatTeam, + GC_MpTextChatFriends, + GC_MpTextChatCrew, + GC_PushToTalk, + GC_CreatorLS, + GC_CreatorRS, + GC_CreatorLT, + GC_CreatorRT, + GC_CreatorMenuToggle, + GC_CreatorAccept, + GC_CreatorDelete, + GC_Attack2, + GC_RappelJump, + GC_RappelLongJump, + GC_RappelSmashWindow, + GC_PrevWeapon, + GC_NextWeapon, + GC_MeleeAttack1, + GC_MeleeAttack2, + GC_Whistle, + GC_MoveLeft, + GC_MoveRight, + GC_MoveUp, + GC_MoveDown, + GC_LookLeft, + GC_LookRight, + GC_LookUp, + GC_LookDown, + GC_SniperZoomIn, + GC_SniperZoomOut, + GC_SniperZoomInAlternate, + GC_SniperZoomOutAlternate, + GC_VehicleMoveLeft, + GC_VehicleMoveRight, + GC_VehicleMoveUp, + GC_VehicleMoveDown, + GC_VehicleGunLeft, + GC_VehicleGunRight, + GC_VehicleGunUp, + GC_VehicleGunDown, + GC_VehicleLookLeft, + GC_VehicleLookRight, + GC_ReplayStartStopRecording, + GC_ReplayStartStopRecordingSecondary, + GC_ScaledLookLeftRight, + GC_ScaledLookUpDown, + GC_ScaledLookUpOnly, + GC_ScaledLookDownOnly, + GC_ScaledLookLeftOnly, + GC_ScaledLookRightOnly, + GC_ReplayMarkerDelete, + GC_ReplayClipDelete, + GC_ReplayPause, + GC_ReplayRewind, + GC_ReplayFfwd, + GC_ReplayNewmarker, + GC_ReplayRecord, + GC_ReplayScreenshot, + GC_ReplayHidehud, + GC_ReplayStartpoint, + GC_ReplayEndpoint, + GC_ReplayAdvance, + GC_ReplayBack, + GC_ReplayTools, + GC_ReplayRestart, + GC_ReplayShowhotkey, + GC_ReplayCycleMarkerLeft, + GC_ReplayCycleMarkerRight, + GC_ReplayFOVIncrease, + GC_ReplayFOVDecrease, + GC_ReplayCameraUp, + GC_ReplayCameraDown, + GC_ReplaySave, + GC_ReplayToggletime, + GC_ReplayToggletips, + GC_ReplayPreview, + GC_ReplayToggleTimeline, + GC_ReplayTimelinePickupClip, + GC_ReplayTimelineDuplicateClip, + GC_ReplayTimelinePlaceClip, + GC_ReplayCtrl, + GC_ReplayTimelineSave, + GC_ReplayPreviewAudio, + GC_VehicleDriveLook, + GC_VehicleDriveLook2, + GC_VehicleFlyAttack2, + GC_RadioWheelUpDown, + GC_RadioWheelLeftRight, + GC_VehicleSlowMoUpDown, + GC_VehicleSlowMoUpOnly, + GC_VehicleSlowMoDownOnly, + GC_MapPointOfInterest +}; \ No newline at end of file diff --git a/LemonUI.SHV/src/Helpers.cpp b/LemonUI.SHV/src/Helpers.cpp new file mode 100644 index 0000000..6512498 --- /dev/null +++ b/LemonUI.SHV/src/Helpers.cpp @@ -0,0 +1,43 @@ +#include "pch.hpp" +#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/src/Helpers.hpp b/LemonUI.SHV/src/Helpers.hpp new file mode 100644 index 0000000..19a1f62 --- /dev/null +++ b/LemonUI.SHV/src/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/src/IDrawable.hpp similarity index 86% rename from LemonUI.SHV/IDrawable.hpp rename to LemonUI.SHV/src/IDrawable.hpp index fe82483..245b735 100644 --- a/LemonUI.SHV/IDrawable.hpp +++ b/LemonUI.SHV/src/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/IRecalculable.hpp b/LemonUI.SHV/src/IRecalculable.hpp similarity index 100% rename from LemonUI.SHV/IRecalculable.hpp rename to LemonUI.SHV/src/IRecalculable.hpp diff --git a/LemonUI.SHV/src/Menus/NativeItem.cpp b/LemonUI.SHV/src/Menus/NativeItem.cpp new file mode 100644 index 0000000..f4a803d --- /dev/null +++ b/LemonUI.SHV/src/Menus/NativeItem.cpp @@ -0,0 +1,39 @@ +#include "pch.hpp" +#include "NativeItem.hpp" +#include "Elements/Font.hpp" +#include "Elements/Alignment.hpp" + +namespace LemonUI +{ + NativeItem::NativeItem(NativeMenu* parent) + { + this->m_parent = parent; + + this->m_text.SetFont(Font::ChaletLondon); + this->m_text.SetAlign(Alignment::Left); + this->m_text.SetScale(0.35f); + + this->m_texture.Set("commonmenu", "gradient_nav"); + } + + bool NativeItem::IsHovering() const + { + return this->m_parent != nullptr ? this->m_parent->SelectedItem() == this : false; + } + + void NativeItem::Render(const Vec2& pos) + { + if (this->IsHovering()) + { + this->m_texture.Render(pos, { this->m_parent->GetWidth(), this->m_height }); + this->m_text.SetColor({ 0.0f, 0.0f, 0.0f, 255.0f }); + } + else + { + this->m_text.SetColor({ 255.0f, 255.0f, 255.0f, 255.0f }); + } + + this->m_text.SetPos({ pos.x, pos.y}); + this->m_text.Draw(); + } +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Menus/NativeItem.hpp b/LemonUI.SHV/src/Menus/NativeItem.hpp new file mode 100644 index 0000000..1371c2a --- /dev/null +++ b/LemonUI.SHV/src/Menus/NativeItem.hpp @@ -0,0 +1,29 @@ +#pragma once +#include "NativeMenu.hpp" +#include "Elements/ScaledText.hpp" +#include "Elements/Texture.hpp" + +namespace LemonUI +{ + class NativeMenu; + + class NativeItem + { + public: + NativeItem(NativeMenu* parent); + + void ChangeText(const std::string& text) { this->m_text.SetText(text); } + + float GetHeight() const { return this->m_height; } + bool IsHovering() const; + + void Render(const Vec2& pos); + + private: + NativeMenu* m_parent = nullptr; + + float m_height = 38; + ScaledText m_text{}; + Texture m_texture{}; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Menus/NativeMenu.cpp b/LemonUI.SHV/src/Menus/NativeMenu.cpp new file mode 100644 index 0000000..0a76b7b --- /dev/null +++ b/LemonUI.SHV/src/Menus/NativeMenu.cpp @@ -0,0 +1,138 @@ +#include "pch.hpp" +#include "NativeMenu.hpp" +#include "GameControl.hpp" + +namespace LemonUI +{ + NativeMenu::NativeMenu() + { + this->m_title.SetFont(Font::HouseScript); + this->m_title.SetAlign(Alignment::Center); + + this->m_subTitle.SetFont(Font::ChaletLondon); + this->m_subTitle.SetScale(0.35f); + this->m_subTitle.SetColor({ 93.0f, 182.0f, 229.0f, 255.0f }); + + this->m_banner.Set("commonmenu", "interaction_bgd"); + this->m_background.Set("commonmenu", "gradient_bgd"); + } + + NativeMenu::~NativeMenu() + { + for (NativeItem* i : this->m_items) + { + delete i; + } + } + + NativeItem* NativeMenu::AddItem() + { + NativeItem* item = new NativeItem(this); + this->m_items.push_back(item); + return item; + } + NativeItem* NativeMenu::AddItem(const std::string& name) + { + NativeItem* item = this->AddItem(); + item->ChangeText(name); + return item; + } + + void NativeMenu::DeleteItem(int index) + { + if (index < 0 || index >= this->m_items.size()) + { + return; + } + + delete this->m_items[index]; + this->m_items.erase(this->m_items.begin() + index); + } + void NativeMenu::DeleteItem(NativeItem* item) + { + std::vector::iterator it = std::find(this->m_items.begin(), this->m_items.end(), item); + if (it != this->m_items.end()) + { + this->m_items.erase(it); + } + delete item; + } + + void NativeMenu::GoUp() + { + this->m_itemSelected--; + if (this->m_itemSelected < 0) + { + this->m_itemSelected = (int)this->m_items.size() - 1; + } + + AUDIO::PLAY_SOUND_FRONTEND(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0); + AUDIO::RELEASE_SOUND_ID(AUDIO::GET_SOUND_ID()); + } + void NativeMenu::GoDown() + { + this->m_itemSelected++; + if (this->m_itemSelected >= this->m_items.size()) + { + this->m_itemSelected = 0; + } + + AUDIO::PLAY_SOUND_FRONTEND(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0); + AUDIO::RELEASE_SOUND_ID(AUDIO::GET_SOUND_ID()); + } + + NativeItem* NativeMenu::SelectedItem() const + { + return (this->m_itemSelected < 0 || this->m_itemSelected >= this->m_items.size()) ? nullptr : this->m_items[this->m_itemSelected]; + } + + float NativeMenu::ContentsHeight() + { + float ret = 0.0f; + for (NativeItem* item : this->m_items) + { + ret += item->GetHeight(); + } + + return ret; + } + + void NativeMenu::Render() + { + if (this->m_items.size() > 0) + { + if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)GameControl::GC_PhoneUp)) + { + this->GoUp(); + } + else if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)GameControl::GC_PhoneDown)) + { + this->GoDown(); + } + } + + Vec2 cursor = this->m_pos; + if (this->m_hasBanner) + { + Vec2 titleRender{ cursor.x + (this->m_width / 2.0f), cursor.y + 20.0f }; + this->m_title.SetPos(titleRender); + this->m_title.Draw(); + this->m_banner.Render(cursor, { this->m_width, 107.0f }); + cursor = { cursor.x, cursor.y + 107.0f }; + } + + Vec2 subTitleRender{ cursor.x + 10.0f, cursor.y + 2.0f }; + this->m_subTitle.SetPos(subTitleRender); + this->m_subTitle.Draw(); + cursor = { cursor.x, cursor.y + 37.0f }; + + this->m_background.Render(cursor, { this->m_width, this->ContentsHeight() }); + + for (int i = 0; i < this->m_items.size(); i++) + { + NativeItem* item = this->m_items[i]; + item->Render(cursor); + cursor = { cursor.x, cursor.y + item->GetHeight() }; + } + } +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Menus/NativeMenu.hpp b/LemonUI.SHV/src/Menus/NativeMenu.hpp new file mode 100644 index 0000000..dcabaf0 --- /dev/null +++ b/LemonUI.SHV/src/Menus/NativeMenu.hpp @@ -0,0 +1,54 @@ +#pragma once +#include "Vectors.hpp" +#include "Elements/ScaledText.hpp" +#include "Elements/Texture.hpp" +#include "NativeItem.hpp" + +#include +#include + +namespace LemonUI +{ + class NativeItem; + + class NativeMenu + { + public: + NativeMenu(); + ~NativeMenu(); + + NativeItem* AddItem(const std::string& text); + NativeItem* AddItem(); + void DeleteItem(int index); + void DeleteItem(NativeItem* item); + + void GoUp(); + void GoDown(); + + NativeItem* SelectedItem() const; + int SelectedIndex() const { return this->m_itemSelected; }; + + float ContentsHeight(); + + float GetWidth() const { return this->m_width; } + + void SetPosition(const Vec2& pos) { this->m_pos = pos; } + + void Render(); + + private: + Vec2 m_pos{ 128, 256 }; + float m_width = 431.0f; + + bool m_hasBanner = true; + + ScaledText m_title{ "LemonUI" }; + ScaledText m_subTitle{ "Test menu" }; + + Texture m_banner{}; + Texture m_background{}; + + std::vector m_items{}; + int m_itemSelected = 0; + }; +} \ No newline at end of file diff --git a/LemonUI.SHV/src/Scaleform/IScaleform.hpp b/LemonUI.SHV/src/Scaleform/IScaleform.hpp new file mode 100644 index 0000000..51105bb --- /dev/null +++ b/LemonUI.SHV/src/Scaleform/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/src/Scaleform/Scaleform.cpp b/LemonUI.SHV/src/Scaleform/Scaleform.cpp new file mode 100644 index 0000000..ec4406c --- /dev/null +++ b/LemonUI.SHV/src/Scaleform/Scaleform.cpp @@ -0,0 +1,75 @@ +#include "pch.hpp" +#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/src/Scaleform/Scaleform.hpp b/LemonUI.SHV/src/Scaleform/Scaleform.hpp new file mode 100644 index 0000000..e8a17a3 --- /dev/null +++ b/LemonUI.SHV/src/Scaleform/Scaleform.hpp @@ -0,0 +1,41 @@ +#pragma once +#include "Scaleform/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/src/Sound.cpp b/LemonUI.SHV/src/Sound.cpp new file mode 100644 index 0000000..28630fb --- /dev/null +++ b/LemonUI.SHV/src/Sound.cpp @@ -0,0 +1,34 @@ +#include "pch.hpp" +#include "Sound.hpp" + +namespace LemonUI +{ + Sound::Sound(std::string set, std::string file) : set{set}, file{file} + {} + + std::string Sound::GetSet() const + { + return this->set; + } + + void Sound::SetSet(const std::string& file) + { + this->set = set; + } + + std::string Sound::GetFile() const + { + return this->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); + AUDIO::RELEASE_SOUND_ID(AUDIO::GET_SOUND_ID()); + } +} diff --git a/LemonUI.SHV/Sound.hpp b/LemonUI.SHV/src/Sound.hpp similarity index 58% rename from LemonUI.SHV/Sound.hpp rename to LemonUI.SHV/src/Sound.hpp index 8268f66..3662b8d 100644 --- a/LemonUI.SHV/Sound.hpp +++ b/LemonUI.SHV/src/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/src/Vectors.hpp b/LemonUI.SHV/src/Vectors.hpp new file mode 100644 index 0000000..776c888 --- /dev/null +++ b/LemonUI.SHV/src/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/src/pch.cpp b/LemonUI.SHV/src/pch.cpp new file mode 100644 index 0000000..7f3196a --- /dev/null +++ b/LemonUI.SHV/src/pch.cpp @@ -0,0 +1 @@ +#include "pch.hpp" \ No newline at end of file diff --git a/LemonUI.SHV/src/pch.hpp b/LemonUI.SHV/src/pch.hpp new file mode 100644 index 0000000..01033d4 --- /dev/null +++ b/LemonUI.SHV/src/pch.hpp @@ -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..6619ad9 --- /dev/null +++ b/premake5.lua @@ -0,0 +1,142 @@ +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 "on" + + targetdir("bin/%{cfg.buildcfg}/%{prj.name}") + objdir("bin-int/%{cfg.buildcfg}/%{prj.name}") + + pchheader "pch.hpp" + pchsource "%{prj.name}/src/pch.cpp" + + prebuildcommands + { + "powershell -Command \"Set-Location ..\\; .\\sdk\\download.ps1\"" + } + + files + { + "LemonUI.SHV/src/**.hpp", + "LemonUI.SHV/src/**.cpp" + } + + includedirs + { + "%{IncludeDir.scripthookv}", + "%{IncludeDir.natives}", + "%{IncludeDir.ikt}", + "LemonUI.SHV/src" + } + + libdirs + { + "%{LibrariesDir.scripthookv}" + } + + links + { + "ScriptHookV" + } + + defines + { + "_CRT_SECURE_NO_WARNINGS" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + runtime "Debug" + symbols "on" + + defines + { + "_DEBUG" + } + + filter "configurations:Release" + runtime "Release" + optimize "on" + +project "LemonUI.SHV.Example" + location "LemonUI.SHV.Example" + kind "SharedLib" + targetextension ".asi" + language "C++" + cppdialect "C++17" + staticruntime "on" + + targetdir("bin/%{cfg.buildcfg}/%{prj.name}") + objdir("bin-int/%{cfg.buildcfg}/%{prj.name}") + + pchheader "pch.hpp" + pchsource "%{prj.name}/src/pch.cpp" + + files + { + "%{prj.name}/src/**.hpp", + "%{prj.name}/src/**.cpp" + } + + includedirs + { + "%{IncludeDir.scripthookv}", + "%{IncludeDir.natives}", + "%{IncludeDir.ikt}", + "%{IncludeDir.lemonui}", + "LemonUI.SHV/src" + } + + libdirs + { + "%{LibrariesDir.scripthookv}", + "%{LibrariesDir.lemonui}" + } + + links + { + "ScriptHookV", + "LemonUI.SHV" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + runtime "Debug" + symbols "on" + + defines + { + "_DEBUG" + } + + filter "configurations:Release" + runtime "Release" + optimize "on" \ No newline at end of file