Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ bld/
*.exe
*.out
*.app

# Custom
**/*.vcxproj*
**/*.sln
!build/*
105 changes: 105 additions & 0 deletions LemonUI.SHV.Example/src/Example.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#pragma once

#include <Helpers.hpp>
#include <Elements/Alignment.hpp>
#include <Elements/ScaledText.hpp>
#include <Scaleform/Scaleform.hpp>
#include <Menus/NativeMenu.hpp>

#include <string>

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;
76 changes: 76 additions & 0 deletions LemonUI.SHV.Example/src/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include "pch.hpp"
#include "Example.hpp"

#include <Helpers.hpp>

#include <natives.hpp>

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;
}
1 change: 1 addition & 0 deletions LemonUI.SHV.Example/src/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "pch.hpp"
3 changes: 3 additions & 0 deletions LemonUI.SHV.Example/src/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include <windows.h>
4 changes: 0 additions & 4 deletions LemonUI.SHV/Alignment.cpp

This file was deleted.

114 changes: 0 additions & 114 deletions LemonUI.SHV/LemonUI.SHV.vcxproj

This file was deleted.

36 changes: 0 additions & 36 deletions LemonUI.SHV/LemonUI.SHV.vcxproj.filters

This file was deleted.

Loading