Batch #14943 by ragnarok-clanker: no function's compiled code changes; checked with 741 compiled unit(s), including every includer of Source/ActorPickNode.h, Source/Client/Browser/BrowserClientSite.h, Source/Client/Browser/BrowserPopupDispatch.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Mode/CMode.h, Source/Client/Mode/ModeDragState.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Client/Stove/StoveMgr.h, Source/Contents/AchievementMgr.h, Source/Contents/ActorNameCard.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/GrannyGameActor.h, Source/Contents/Actors/GroundScope.h, Source/Contents/Actors/Item.h, Source/Contents/Actors/Npc.h, Source/Contents/Actors/Pc.h, Source/Contents/Actors/RenderObjectState.h, Source/Contents/Actors/Skill.h, Source/Contents/AdventureGuideMgr.h, Source/Contents/Camera/Camera.h, Source/Contents/Camera/CameraState.h, Source/Contents/CashEmotionMgr.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/EffectResourceSwitcher.h, Source/Contents/Effects/AMachineEffect.h, Source/Contents/Effects/AcidifiedThrow.h, Source/Contents/Effects/AxeBoomerang.h, Source/Contents/Effects/BlastForge.h, Source/Contents/Effects/CaneOfEvilEyeEffect.h, Source/Contents/Effects/CharacterParticleBundle.h, Source/Contents/Effects/CloudKillEffect.h, Source/Contents/Effects/Effect.h, Source/Contents/Effects/EffectActor.h, Source/Contents/Effects/EffectEmitter.h, Source/Contents/Effects/EffectMaker.h, Source/Contents/Effects/EffectPrimitiveState.h, Source/Contents/Effects/FuumaShouakuEffect.h, Source/Contents/Effects/GravityControlEffect.h, Source/Contents/Effects/HealSpEffect.h, Source/Contents/Effects/Level99Effect.h, Source/Contents/Effects/MapChainEffect.h, Source/Contents/Effects/MonsterSkillEffects.h, Source/Contents/Effects/MsgEffect.h, Source/Contents/Effects/NyanggrassEffect.h, Source/Contents/Effects/Particle.h, Source/Contents/Effects/PowderingEffect.h, Source/Contents/Effects/RagEffectState.h, Source/Contents/Effects/RectUpEffect.h, Source/Contents/Effects/ShadowExceedEffect.h, Source/Contents/Effects/SkillEffects.h, Source/Contents/Effects/SpriteParticle.h, Source/Contents/Effects/StormCannonEffect.h, Source/Contents/Effects/ThrowEffects.h, Source/Contents/EntryQueueMgr.h, Source/Contents/EquipmentResourceMgr.h, Source/Contents/FlyingShipRouteInfo.h, Source/Contents/Ground/GroundGeometry.h, Source/Contents/GuildInfo.h, Source/Contents/Items/ItemDescription.h, Source/Contents/Items/ItemInfo.h, Source/Contents/MapSkyMgr.h, Source/Contents/Messenger/MessengerWindows.h, Source/Contents/Models/ModelNode.h, Source/Contents/NavigationManager.h, Source/Contents/Party/AdventurerAgencyMgr.h, Source/Contents/RDamageVar.h, Source/Contents/RenewQuestMgr.h, Source/Contents/ReputeMgr.h, Source/Contents/RodexMailStore.h, Source/Contents/RouletteMgr.h, Source/Contents/Schedule/Schedule.h, Source/Contents/SignBoard/SignBoard.h, Source/Contents/Skills/ClientSkills.h, Source/Contents/Skills/PlayerSkillBundle.h, Source/Contents/Skills/SkillInfo.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/TipBoxTitles.h, Source/Contents/UserData/AccountLinkedUserDataMgr.h, Source/Contents/UserData/NormalItemSlots.h, Source/Contents/World/World.h, Source/Contents/WorldView/WorldViewData.h, Source/Render/Primitives/LightmappedPrimitive.h, Source/Render/Primitives/RenderPrimitive.h, Source/Render/Renderer.h, Source/Render/Textures/SpritePixels.h, Source/Render/Textures/Texture.h, Source/Resource/EZeffectResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Sprites/ActionResource.h, Source/Resource/World/GroundResource.h, Source/Resource/World/WorldResource.h, Source/Resource/XmlNode.h, Source/UI/AdventureGuide/UIAdventureGuide.h, Source/UI/Buttons/UIBmpRadioBtn.h, Source/UI/Buttons/UIDescriptRace.h, Source/UI/Buttons/UIItemTagButton.h, Source/UI/Buttons/UISlotBmpButton.h, Source/UI/Buttons/UISpriteButton.h, Source/UI/Buttons/UITVTextButton.h, Source/UI/Buttons/UITextureButton.h, Source/UI/CashEmotion/UICashEmotionListWnd.h, Source/UI/CashEmotion/UICashEmotionPack.h, Source/UI/CashShop/UICashShopWnd.h, Source/UI/Chat/UIChatRoomMakeWnd.h, Source/UI/Chat/UIChatRoomTitle.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Chat/UISubChatHisWnd.h, Source/UI/Chat/UISubChatMiniWnd.h, Source/UI/Chat/UIWhisperWnd.h, Source/UI/Clan/UIClanWnd.h, Source/UI/Dialogs/UIBookWnd.h, Source/UI/Dialogs/UIChooseWarpWnd.h, Source/UI/Dialogs/UIMenuWnd.h, Source/UI/Dialogs/UIMiniMapWnd.h, Source/UI/Dialogs/UIMinimapZoomWnd.h, Source/UI/Dialogs/UINpcEditDialogWnd.h, Source/UI/Dialogs/UIPasswordWnd.h, Source/UI/Dialogs/UISayDialogWnd.h, Source/UI/Dialogs/UISelectCartWnd.h, Source/UI/Dialogs/UITipboxWnd.h, Source/UI/Edit/UIEditBoxEx.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Edit/UIEditCtrl_Currency.h, Source/UI/Edit/UIItemTagCtrl.h, Source/UI/Enchant/EnchantUI.h, Source/UI/Exchange/UIExchangeUI.h, Source/UI/FrameSkin.h, Source/UI/GameSettings/GameSettingsUI.h, Source/UI/Gauges/UIPcGage.h, Source/UI/Guild/UIGuildHelperWnd.h, Source/UI/Guild/UIGuildWnd.h, Source/UI/Guild/UIGuild_Storage_Log.h, Source/UI/Item/UIEquipmentPropertiesWnd.h, Source/UI/Item/UIItemBaseWnd.h, Source/UI/Item/UIItemPurchaseWnd.h, Source/UI/Item/UIItemSellWnd2.h, Source/UI/Item/UIItemShopWnd.h, Source/UI/Item/UIItemShopWnd2.h, Source/UI/Item/UIItemStoreFindWnd.h, Source/UI/Item/UIItemStoreSubWnd.h, Source/UI/Item/UIItemStoreWnd.h, Source/UI/Item/UIItemWnd.h, Source/UI/Item/UIMerchantItemLogWnd.h, Source/UI/Item/UIParaItemShopWnd.h, Source/UI/Items/UICardItemIllustWnd.h, Source/UI/Items/UIEquipWnd.h, Source/UI/Items/UIExchangeWnd.h, Source/UI/Items/UIGameItem.h, Source/UI/Items/UIItemCollectionWnd.h, Source/UI/Items/UIItemIdentifyWnd.h, Source/UI/Items/UIItemParamChangeDisplayWnd.h, Source/UI/Items/UISwapEquipmentWnd.h, Source/UI/Layout/WindowGeometry.h, Source/UI/Lists/UIChatHisBox.h, Source/UI/Lists/UIComboBoxV2Wnd.h, Source/UI/Lists/UIImgMenu.h, Source/UI/Lists/UIListBoxID.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Lists/UIMemberListBox.h, Source/UI/Lists/UITabControl.h, Source/UI/Lists/UITagListBox.h, Source/UI/Lists/UITreeView.h, Source/UI/Menu/UIMenuIconWnd.h, Source/UI/Navigation/UINavigationV4Wnd.h, Source/UI/ProbabilityTable/UIProbabilityTable.h, Source/UI/Quest/UIQuestDisplay.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Quest/UIRenewQuestWnd.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Rodex/UIRodexInboxWnd.h, Source/UI/RuneSystem/UIRuneSystemWindows.h, Source/UI/RuneSystem/UIRuneSystemWnd.h, Source/UI/Shop/UIMerchantItemMyShopWnd.h, Source/UI/Shop/UIMerchantItemPurchaseMSGWnd.h, Source/UI/Shop/UIMerchantItemPurchaseWnd.h, Source/UI/Shop/UIMerchantItemShopWnd.h, Source/UI/Shop/UIMerchantMirrorItemWnd.h, Source/UI/Shop/UIMerchantShopMakeWnd.h, Source/UI/Shop/UIMerchantShopTitle.h, Source/UI/Skill/UISkillDescribeWnd.h, Source/UI/Skill/UISkillListWnd.h, Source/UI/SkillDelayInfo/SkillDelayInfo.h, Source/UI/StylingShop/UIStylingShopWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/Text/UIAchWnd.h, Source/UI/Text/UIBalloonText.h, Source/UI/Text/UINameBalloonText.h, Source/UI/Text/UIStaticTextControl.h, Source/UI/Text/UIString.h, Source/UI/Text/UITextViewerControl.h, Source/UI/UIBarGraph.h, Source/UI/UIBartermarketWnd.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/UILapineScrollBar.h, Source/UI/UIMacroBlackListCheckWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIMacroReport.h, Source/UI/UIMacroUserInfoWnd.h, Source/UI/UIPreviewEquipWnd.h, Source/UI/UIRefiningWnd.h, Source/UI/UIScrollWnd.h, Source/UI/UISlotBitmap.h, Source/UI/Window/FuncDrawWNDChar.h, Source/UI/Window/UIBattleMsgOptionWnd.h, Source/UI/Window/UIChatRoomWnd.h, Source/UI/Window/UICollectionSystemWnd.h, Source/UI/Window/UIControl.h, Source/UI/Window/UIHomunInfoWnd.h, Source/UI/Window/UIHotKeyWnd.h, Source/UI/Window/UIJobListWnd.h, Source/UI/Window/UILoginOTPWnd.h, Source/UI/Window/UILoginWnd.h, Source/UI/Window/UIMakeCharWnd.h, Source/UI/Window/UIMonsterDisplayWnd.h, Source/UI/Window/UIMonsterInfoWnd.h, Source/UI/Window/UINavigationHelpWnd.h, Source/UI/Window/UINavigationWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/UI/Window/UINoticeWnd.h, Source/UI/Window/UIPetInfoWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UIRoMapWnd.h, Source/UI/Window/UIRodexContentsWnd.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISeekPartyMBWnd.h, Source/UI/Window/UISeekPartyWnd.h, Source/UI/Window/UISelCharForUServerWnd.h, Source/UI/Window/UISerachStoreInfoWnd.h, Source/UI/Window/UITransMenuWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl, Source/Utility/Lexicon/LexiconSerializer.h.
577 lines
16 KiB
C++
577 lines
16 KiB
C++
#include "Contents/TipBoxTitles.h"
|
|
#include "Client/Input/InputCharset.h"
|
|
#include "Resource/Bitmap/BitmapResource.h"
|
|
#include "Resource/ResourceMgr.h"
|
|
#include "Resource/Sprites/SpriteResource.h"
|
|
#include "Resource/TextureNames.h"
|
|
#include "Script/NLuaState.h"
|
|
#include "Utility/Cipher/XorBytes.h"
|
|
|
|
extern "C" {
|
|
#include <lauxlib.h>
|
|
#include <lua.h>
|
|
#include <lualib.h>
|
|
}
|
|
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <mbstring.h>
|
|
#include <new>
|
|
#include <windows.h>
|
|
|
|
// GLOBAL: gl_24607
|
|
CTipBoxMgr* g_itemTagOwner = nullptr;
|
|
|
|
namespace {
|
|
template <std::size_t Length, std::uint64_t Key>
|
|
class EncryptedName {
|
|
public:
|
|
// INLINED
|
|
explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) {
|
|
for (std::uint64_t index = 0; index < Length; ++index) {
|
|
this->m_text[index] = source[index];
|
|
}
|
|
}
|
|
|
|
~EncryptedName() {
|
|
for (std::uint64_t index = 0; index < Length; ++index) {
|
|
this->m_text[index] = 0;
|
|
}
|
|
}
|
|
|
|
const char* Text() {
|
|
if (this->m_encrypted) {
|
|
utility::XorBytes(this->m_text, Length, Key);
|
|
this->m_encrypted = false;
|
|
}
|
|
|
|
return reinterpret_cast<const char*>(this->m_text);
|
|
}
|
|
|
|
private:
|
|
std::uint8_t m_text[Length];
|
|
bool m_encrypted;
|
|
};
|
|
|
|
// INLINED
|
|
template <std::uint64_t Key, std::size_t Length>
|
|
const char* DecryptName(const char (&source)[Length]) {
|
|
thread_local EncryptedName<Length, Key> name(source);
|
|
return name.Text();
|
|
}
|
|
|
|
// OFFSET: 0x009B45D0
|
|
// FUNCTION: fn_13832
|
|
__declspec(noinline) void SplitTitle(const char* text, std::vector<std::string>& lines, int width) {
|
|
const char* begin = text;
|
|
const char* current = text;
|
|
const char* end = text + std::char_traits<char>::length(text);
|
|
const char* limit = text + width;
|
|
|
|
while (current < end) {
|
|
if (current >= limit || *current == '\n') {
|
|
const std::string line(begin, current);
|
|
lines.push_back(line);
|
|
begin = current;
|
|
limit = current + width;
|
|
}
|
|
|
|
current = g_serverLanguage->NextChar(current, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x007ABEC0
|
|
// FUNCTION: fn_09118
|
|
TipBoxEntry::TipBoxEntry() {
|
|
}
|
|
|
|
// INLINED
|
|
CTipBoxMgr::CTipBoxMgr()
|
|
: m_width(240),
|
|
m_height(320),
|
|
m_maximumId(17),
|
|
m_entries{},
|
|
m_randomList{},
|
|
m_currentEntry{},
|
|
m_image{},
|
|
m_imagePath{},
|
|
paragraphIndex(0),
|
|
m_initialized(true),
|
|
m_missing{},
|
|
currentTipId(0),
|
|
maxTipId(0) {
|
|
}
|
|
|
|
// INLINED
|
|
CTipBoxMgr::~CTipBoxMgr() = default;
|
|
|
|
// OFFSET: 0x007AC710
|
|
// FUNCTION: fn_09122
|
|
void CTipBoxMgr::AddParagraph(int id, std::string text) {
|
|
{
|
|
const std::string newline("\n");
|
|
const std::string escaped("\\n");
|
|
|
|
for (;;) {
|
|
const auto pos = text.find(escaped);
|
|
if (pos == std::string::npos) {
|
|
break;
|
|
}
|
|
text.replace(pos, escaped.size(), newline);
|
|
}
|
|
}
|
|
|
|
this->m_entries[id].paragraphs.push_back(text);
|
|
}
|
|
|
|
// OFFSET: 0x007AC990
|
|
// FUNCTION: fn_09123
|
|
bool CTipBoxMgr::Create() {
|
|
if (g_itemTagOwner) {
|
|
return false;
|
|
}
|
|
|
|
g_itemTagOwner = new (std::nothrow) CTipBoxMgr();
|
|
if (!g_itemTagOwner) {
|
|
return false;
|
|
}
|
|
|
|
if (!g_itemTagOwner->m_initialized) {
|
|
delete g_itemTagOwner;
|
|
g_itemTagOwner = nullptr;
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// OFFSET: 0x007ACB20
|
|
// FUNCTION: fn_09124
|
|
void CTipBoxMgr::Destroy() {
|
|
if (g_itemTagOwner) {
|
|
delete g_itemTagOwner;
|
|
g_itemTagOwner = nullptr;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x007ACB40
|
|
// FUNCTION: fn_09125
|
|
TipBoxEntry& CTipBoxMgr::SelectRandomTip() {
|
|
this->m_randomList.clear();
|
|
|
|
for (auto it = this->m_entries.begin(); it != this->m_entries.end(); ++it) {
|
|
if (it->first < 1000 && it->second.randomEligible == 1) {
|
|
this->m_randomList.push_back(it->first);
|
|
}
|
|
}
|
|
|
|
const auto count = this->m_randomList.size();
|
|
this->SelectTip(this->m_randomList[static_cast<unsigned>(rand()) % count]);
|
|
return this->m_currentEntry;
|
|
}
|
|
|
|
// OFFSET: 0x007ACC00
|
|
// FUNCTION: fn_09126
|
|
const TipBoxEntry& CTipBoxMgr::GetTip(int id) const {
|
|
if (this->m_entries.find(id) != this->m_entries.end()) {
|
|
return this->m_entries.find(id)->second;
|
|
}
|
|
|
|
return this->m_missing;
|
|
}
|
|
|
|
// OFFSET: 0x007ACC70
|
|
// FUNCTION: fn_09127
|
|
std::string CTipBoxMgr::Title(int id, std::string* abbreviated, int width) const {
|
|
const std::string& title = this->GetTip(id).title;
|
|
|
|
if (title.size() == 0) {
|
|
return title;
|
|
}
|
|
|
|
std::size_t length = title.find("#");
|
|
if (length == std::string::npos) {
|
|
length = title.size();
|
|
}
|
|
std::string result = title.substr(0, length);
|
|
|
|
if (abbreviated) {
|
|
if (width > 10 && result.size() > static_cast<std::size_t>(width + 4)) {
|
|
std::vector<std::string> lines;
|
|
SplitTitle(result.c_str(), lines, width);
|
|
*abbreviated = lines[0] + "...";
|
|
} else {
|
|
*abbreviated = result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// OFFSET: 0x007ACF50
|
|
// FUNCTION: fn_09128
|
|
void CTipBoxMgr::Sub7ACF50() {
|
|
const TipBoxEntry& entry = this->m_currentEntry;
|
|
|
|
if (entry.bitmapName.size() == 0) {
|
|
this->m_image.kind = 2;
|
|
return;
|
|
}
|
|
|
|
const int cell = entry.imageCell - 1;
|
|
const float cellWidth = static_cast<float>(this->m_width) / 3.0f;
|
|
const int row = cell / 3;
|
|
const int column = cell % 3;
|
|
const float cellHeight = static_cast<float>(this->m_height) / 3.0f;
|
|
const std::size_t found = entry.bitmapName.find("유저인터페이스\\");
|
|
|
|
this->m_image.x = static_cast<float>(column) * cellWidth + cellWidth * 0.5f;
|
|
this->m_image.y = static_cast<float>(this->m_maximumId) + cellHeight * 0.5f + static_cast<float>(row) * cellHeight;
|
|
|
|
if (found != std::string::npos) {
|
|
this->m_imagePath = entry.bitmapName + ".bmp";
|
|
|
|
const auto* bitmap = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve(this->m_imagePath.c_str())));
|
|
if (!bitmap) {
|
|
return;
|
|
}
|
|
|
|
const float scale = static_cast<float>(entry.imageScalePercent) * 0.01f;
|
|
this->m_image.x -= static_cast<float>(bitmap->image.width) * 0.5f * scale;
|
|
this->m_image.y -= static_cast<float>(bitmap->image.height) * 0.5f * scale;
|
|
|
|
if (1.0f > this->m_image.x) {
|
|
const float clip = 1.0f - this->m_image.x;
|
|
this->m_image.x = 1.0f;
|
|
this->m_image.clipX = static_cast<int>(clip);
|
|
} else {
|
|
this->m_image.clipX = 0;
|
|
}
|
|
|
|
if (17.0f > this->m_image.y) {
|
|
this->m_image.clipY = static_cast<int>(17.0f - this->m_image.y);
|
|
this->m_image.y = static_cast<float>(this->m_maximumId);
|
|
} else {
|
|
this->m_image.clipY = 0;
|
|
}
|
|
|
|
this->m_image.width = static_cast<float>(bitmap->image.width) * scale;
|
|
this->m_image.kind = 0;
|
|
this->m_image.scale = scale;
|
|
this->m_image.height = static_cast<float>(bitmap->image.height) * scale;
|
|
} else {
|
|
this->m_imagePath = "sprite\\" + entry.bitmapName;
|
|
|
|
const auto* sprite = static_cast<CSprRes*>(ResourceMgr::Instance().Load(this->m_imagePath + ".spr"));
|
|
if (!sprite) {
|
|
return;
|
|
}
|
|
|
|
const SpriteRleImage* image = sprite->images[0][0];
|
|
if (!image) {
|
|
return;
|
|
}
|
|
|
|
const float scale = static_cast<float>(entry.imageScalePercent) * 0.01f;
|
|
const float ratio = static_cast<float>(entry.imageScalePercent) / 100.0f;
|
|
this->m_image.x -= static_cast<float>(image->width) * 0.5f * scale;
|
|
this->m_image.y -= static_cast<float>(image->height) * 0.5f * scale;
|
|
|
|
const float right = static_cast<float>(image->width) * ratio + this->m_image.x;
|
|
if (right > static_cast<float>(this->m_width)) {
|
|
this->m_image.x -= right - static_cast<float>(this->m_width);
|
|
}
|
|
|
|
const float bottom = static_cast<float>(image->height) * ratio + this->m_image.y;
|
|
if (bottom > static_cast<float>(this->m_height)) {
|
|
this->m_image.y -= bottom - static_cast<float>(this->m_height);
|
|
}
|
|
|
|
this->m_image.width = static_cast<float>(image->width) * scale;
|
|
this->m_image.scale = scale;
|
|
this->m_image.kind = 1;
|
|
this->m_image.height = static_cast<float>(image->height) * scale;
|
|
}
|
|
}
|
|
|
|
// INLINED
|
|
inline void CTipBoxMgr::AddTip(int id, std::string title, double flag, std::string text) {
|
|
if (this->maxTipId < id) {
|
|
this->maxTipId = id;
|
|
}
|
|
this->m_entries[id].title = title;
|
|
this->m_entries[id].randomEligible = static_cast<int>(flag) == 1;
|
|
this->m_entries[id].bitmapName = text;
|
|
}
|
|
|
|
int AddTip(lua_State* state);
|
|
int AddImgcoord(lua_State* state);
|
|
int AddPageEx(lua_State* state);
|
|
int AddPage(lua_State* state);
|
|
int AddIsTag(lua_State* state);
|
|
|
|
// OFFSET: 0x007AD480
|
|
// FUNCTION: fn_09129
|
|
bool CTipBoxMgr::RegisterLuaFunctions() {
|
|
NLuaState state;
|
|
if (!state.IsValid()) {
|
|
return false;
|
|
}
|
|
|
|
luaL_openlibs(state.GetState());
|
|
lua_register(state.GetState(), "AddTip", ::AddTip);
|
|
lua_register(state.GetState(), "AddImgcoord", AddImgcoord);
|
|
lua_register(state.GetState(), "AddPageEx", AddPageEx);
|
|
lua_register(state.GetState(), "AddPage", AddPage);
|
|
lua_register(state.GetState(), "AddIsTag", AddIsTag);
|
|
|
|
const char source[] = {'\xF4', '\xCA', '\x76', '\xBD', '\xC0', '\x0E', '\xB7', '\x7F', '\xCE', '\xC3', '\x67', '\xA6', '\xDD', '\x4D', '\x87', '\x7E', '\xC6', '\xB3'};
|
|
|
|
if (luaL_loadfile(state.GetState(), DecryptName<0x0BEB63A5C905B3A7ULL>(source)) != 0) {
|
|
const char secondSource[] = {'\x9A', '\xCE', '\x56', '\xE3', '\xDE', '\x5E', '\xDF', '\x73', '\xA0', '\xC7', '\x47', '\xF8', '\xC3', '\x1D', '\xEF', '\x72', '\xAB', '\xB7'};
|
|
|
|
if (luaL_loadfile(state.GetState(), DecryptName<0x078333BB9725B7C9ULL>(secondSource)) != 0) {
|
|
MessageBoxA(nullptr, lua_tostring(state.GetState(), -1), "TipBox", MB_OK);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (lua_pcall(state.GetState(), 0, 0, 0) != 0) {
|
|
MessageBoxA(nullptr, lua_tostring(state.GetState(), -1), "TipBox", MB_OK);
|
|
return false;
|
|
}
|
|
|
|
lua_getglobal(state.GetState(), "main");
|
|
if (lua_pcall(state.GetState(), 0, 2, 0) != 0) {
|
|
MessageBoxA(nullptr, lua_tostring(state.GetState(), -1), "TipBox", MB_OK);
|
|
return false;
|
|
}
|
|
|
|
if (!lua_isstring(state.GetState(), -1)) {
|
|
MessageBoxA(nullptr, "second return value is not string...", "TipBox", MB_OK);
|
|
return false;
|
|
}
|
|
|
|
if (lua_toboolean(state.GetState(), -2)) {
|
|
return true;
|
|
}
|
|
|
|
const std::string message = std::string("error found :") + lua_tostring(state.GetState(), -1);
|
|
MessageBoxA(nullptr, message.c_str(), "TipBox", MB_OK);
|
|
return false;
|
|
}
|
|
|
|
// OFFSET: 0x007AD890
|
|
// FUNCTION: fn_09130
|
|
bool CTipBoxMgr::IsLastTip() const {
|
|
return this->paragraphIndex == static_cast<int>(this->m_currentEntry.paragraphs.size()) - 1;
|
|
}
|
|
|
|
// OFFSET: 0x007AD8C0
|
|
// FUNCTION: fn_09131
|
|
bool CTipBoxMgr::HasImages() const {
|
|
return !this->m_currentEntry.images.empty();
|
|
}
|
|
|
|
// OFFSET: 0x007AD8D0
|
|
// FUNCTION: fn_09132
|
|
bool CTipBoxMgr::HasSearchResults() const {
|
|
return !this->m_randomList.empty();
|
|
}
|
|
|
|
// OFFSET: 0x007AD940
|
|
// FUNCTION: fn_09133
|
|
std::vector<int>& CTipBoxMgr::Search(std::string& keyword) {
|
|
this->m_randomList.clear();
|
|
|
|
for (auto it = this->m_entries.begin(); it != this->m_entries.end(); ++it) {
|
|
const TipBoxEntry entry = it->second;
|
|
|
|
if (!entry.randomEligible) {
|
|
continue;
|
|
}
|
|
|
|
std::string title = entry.title;
|
|
std::transform(title.begin(), title.end(), title.begin(), [](unsigned char c) { return static_cast<char>(toupper(c)); });
|
|
std::transform(keyword.begin(), keyword.end(), keyword.begin(), [](unsigned char c) { return static_cast<char>(toupper(c)); });
|
|
|
|
if (_mbsstr(reinterpret_cast<const unsigned char*>(title.c_str()), reinterpret_cast<const unsigned char*>(keyword.c_str()))) {
|
|
this->m_randomList.push_back(it->first);
|
|
}
|
|
}
|
|
|
|
return this->m_randomList;
|
|
}
|
|
|
|
// OFFSET: 0x007AE050
|
|
// FUNCTION: fn_09134
|
|
void CTipBoxMgr::SelectTip(int id) {
|
|
this->paragraphIndex = 0;
|
|
|
|
const auto it = this->m_entries.find(id);
|
|
if (it != this->m_entries.end()) {
|
|
this->currentTipId = id;
|
|
this->m_currentEntry = it->second;
|
|
}
|
|
|
|
this->Sub7ACF50();
|
|
}
|
|
|
|
// OFFSET: 0x007AEAF0
|
|
// FUNCTION: fn_09145
|
|
int AddPage(lua_State* state) {
|
|
if (!lua_isnumber(state, -2)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "2st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isstring(state, -1)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "1th argment is must string");
|
|
return 2;
|
|
}
|
|
|
|
const int id = static_cast<int>(lua_tonumber(state, -2));
|
|
const char* text = lua_tostring(state, -1);
|
|
CTipBoxMgr* owner = g_itemTagOwner;
|
|
owner->AddParagraph(id, text);
|
|
lua_pushboolean(state, 1);
|
|
lua_pushstring(state, "good");
|
|
return 2;
|
|
}
|
|
|
|
// OFFSET: 0x007AE900
|
|
// FUNCTION: fn_09143
|
|
int AddImgcoord(lua_State* state) {
|
|
if (!lua_isnumber(state, -1)) { lua_pushboolean(state, 0); lua_pushstring(state, "3nd argment is must number"); return 2; }
|
|
if (!lua_isnumber(state, -2)) { lua_pushboolean(state, 0); lua_pushstring(state, "2nd argment is must number"); return 2; }
|
|
if (!lua_isnumber(state, -3)) { lua_pushboolean(state, 0); lua_pushstring(state, "1st argment is must number"); return 2; }
|
|
|
|
const int id = static_cast<int>(lua_tonumber(state, -3));
|
|
const int x = static_cast<int>(lua_tonumber(state, -2));
|
|
const int y = static_cast<int>(lua_tonumber(state, -1));
|
|
g_itemTagOwner->SetImageCoord(id, x, y);
|
|
lua_pushboolean(state, 1);
|
|
lua_pushstring(state, "good");
|
|
return 2;
|
|
}
|
|
|
|
// OFFSET: 0x007AEA20
|
|
// FUNCTION: fn_09144
|
|
int AddIsTag(lua_State* state) {
|
|
if (!lua_isnumber(state, -2)) { lua_pushboolean(state, 0); lua_pushstring(state, "2 argment is must number"); return 2; }
|
|
if (!lua_isnumber(state, -1)) { lua_pushboolean(state, 0); lua_pushstring(state, "1 argment is must number"); return 2; }
|
|
|
|
const int id = static_cast<int>(lua_tonumber(state, -2));
|
|
g_itemTagOwner->SetSearchable(id, static_cast<int>(lua_tonumber(state, -1)) != 0);
|
|
lua_pushboolean(state, 1);
|
|
lua_pushstring(state, "good");
|
|
return 2;
|
|
}
|
|
|
|
// OFFSET: 0x007AEC00
|
|
// FUNCTION: fn_09146
|
|
int AddTip(lua_State* state) {
|
|
if (!lua_isstring(state, -1)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "4th argment is must string");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -2)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "3nd argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isstring(state, -3)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "2st argment is must string");
|
|
return 2;
|
|
}
|
|
if (lua_tonumber(state, -4) == 0.0) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "1st argment is must number");
|
|
return 2;
|
|
}
|
|
|
|
const int id = static_cast<int>(lua_tonumber(state, -4));
|
|
const char* title = lua_tostring(state, -3);
|
|
const double flag = lua_tonumber(state, -2);
|
|
const char* text = lua_tostring(state, -1);
|
|
g_itemTagOwner->AddTip(id, title, flag, text);
|
|
lua_pushboolean(state, 1);
|
|
lua_pushstring(state, "good");
|
|
return 2;
|
|
}
|
|
|
|
// OFFSET: 0x007AE600
|
|
// FUNCTION: fn_09142
|
|
int AddPageEx(lua_State* state) {
|
|
if (!lua_isnumber(state, -1)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "8nd argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -2)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "7nd argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -3)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "6st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -4)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "5st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -5)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "4st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -6)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "3st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -7)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "2st argment is must number");
|
|
return 2;
|
|
}
|
|
if (!lua_isnumber(state, -8)) {
|
|
lua_pushboolean(state, 0);
|
|
lua_pushstring(state, "1st argment is must number");
|
|
return 2;
|
|
}
|
|
|
|
int id = static_cast<int>(lua_tonumber(state, -8));
|
|
const int kind = static_cast<int>(lua_tonumber(state, -7));
|
|
const double x = lua_tonumber(state, -6);
|
|
const double y = lua_tonumber(state, -5);
|
|
const double width = lua_tonumber(state, -4);
|
|
const double height = lua_tonumber(state, -3);
|
|
const double clipX = lua_tonumber(state, -2);
|
|
const float scale = static_cast<float>(lua_tonumber(state, -1));
|
|
if (kind != -1 && id > 0) {
|
|
TipBoxImage image;
|
|
image.kind = kind;
|
|
image.blink = static_cast<int>(x);
|
|
image.fromX = static_cast<int>(y);
|
|
image.fromY = static_cast<int>(width);
|
|
image.toX = static_cast<int>(height);
|
|
image.toY = static_cast<int>(clipX);
|
|
image.duration = scale;
|
|
g_itemTagOwner->AddImage(id, image);
|
|
}
|
|
|
|
lua_pushboolean(state, 1);
|
|
lua_pushstring(state, "good");
|
|
return 2;
|
|
}
|