Skip to content

Commit fd032c8

Browse files
committed
hotfix for events - on save map wont insert txts to non existing event arcs
1 parent 9063225 commit fd032c8

File tree

9 files changed

+625
-290
lines changed

9 files changed

+625
-290
lines changed

include/DOM/EventDataDOMNode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class LEventDataDOMNode : public LBGRenderDOMNode {
3535
LEventDataDOMNode(std::string name);
3636

3737
void LoadEventArchive(std::shared_ptr<Archive::Rarc> arc, std::filesystem::path eventPath, std::string eventScriptName, std::string eventCsvName);
38-
void SaveEventArchive();
38+
void SaveEventArchive(bool createIfNotExist=true);
3939

4040
void RenderDetailsUI(float dt, TextEditor* event);
4141
void RenderHierarchyUI(std::shared_ptr<LEventDataDOMNode> self, LEditorSelection* mode_selection);

include/io/BtiIO.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#pragma once
2+
#include "bstream.h"
3+
4+
namespace ImageFormat {
5+
namespace Decode {
6+
void CMPR(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
7+
8+
void RGB5A3(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
9+
void RGB565(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
10+
11+
void I4(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
12+
void I8(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
13+
14+
void IA4(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
15+
void IA8(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
16+
}
17+
18+
namespace Encode {
19+
void CMPR(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
20+
void RGB5A3(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
21+
void RGB565(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
22+
23+
24+
void I4(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
25+
void I8(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
26+
27+
void IA4(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
28+
void IA8(bStream::CStream* stream, uint16_t width, uint16_t height, uint8_t* imageData);
29+
}
30+
};
31+
32+
namespace Bti {
33+
uint8_t* DecodeImage(bStream::CStream* stream, uint32_t& w, uint32_t& h);
34+
}

res/names/MapTitlecards.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"titlecards":[
3+
"e_kyukei.bti",
4+
"e_secret.bti",
5+
"e_entran.bti",
6+
"e_uranai.bti",
7+
"e_mirror.bti",
8+
"e_1f.bti",
9+
"e_1f.bti",
10+
"e_1f.bti",
11+
"e_1f.bti",
12+
"e_1f.bti",
13+
"e_1f.bti",
14+
"e_1f.bti",
15+
"e_1f.bti",
16+
"e_1f.bti",
17+
"e_1f.bti",
18+
"e_1f.bti",
19+
"e_1f.bti",
20+
"e_1f.bti",
21+
"e_1f.bti",
22+
"e_1f.bti",
23+
"e_1f.bti",
24+
"e_1f.bti",
25+
"e_1f.bti",
26+
"e_1f.bti",
27+
"e_1f.bti",
28+
"e_1f.bti",
29+
"e_1f.bti",
30+
"e_1f.bti",
31+
"e_1f.bti",
32+
"e_1f.bti",
33+
"e_1f.bti",
34+
"e_1f.bti",
35+
"e_1f.bti",
36+
"e_1f.bti",
37+
"e_1f.bti",
38+
"e_1f.bti",
39+
"e_1f.bti",
40+
"e_1f.bti",
41+
"e_1f.bti",
42+
"e_1f.bti",
43+
"e_1f.bti",
44+
"e_1f.bti",
45+
"e_1f.bti",
46+
"e_1f.bti",
47+
"e_1f.bti",
48+
"e_1f.bti",
49+
"e_1f.bti",
50+
"e_1f.bti",
51+
"e_1f.bti",
52+
"e_1f.bti",
53+
"e_1f.bti",
54+
"e_1f.bti",
55+
"e_1f.bti",
56+
"e_1f.bti",
57+
"e_1f.bti",
58+
"e_1f.bti",
59+
"e_1f.bti",
60+
"e_1f.bti",
61+
"e_1f.bti",
62+
"e_1f.bti",
63+
"e_1f.bti",
64+
"e_1f.bti",
65+
"e_1f.bti",
66+
"e_1f.bti",
67+
"e_1f.bti",
68+
"e_1f.bti",
69+
"e_1f.bti",
70+
"e_1f.bti",
71+
"e_1f.bti",
72+
"e_1f.bti",
73+
"e_1f.bti",
74+
"e_1f.bti",
75+
"e_1f.bti",
76+
"e_1f.bti"
77+
]
78+
}

src/DOM/EventDataDOMNode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void LEventDataDOMNode::LoadEventArchive(std::shared_ptr<Archive::Rarc> arc, std
114114

115115
}
116116

117-
void LEventDataDOMNode::SaveEventArchive(){
117+
void LEventDataDOMNode::SaveEventArchive(bool createIfNotExist){
118118
std::shared_ptr<Archive::File> msgFile = mEventArchive->GetFile(std::filesystem::path("message") / std::string(mEventMessagePath + ".csv"));
119119
std::shared_ptr<Archive::File> txtFile = mEventArchive->GetFile(std::filesystem::path("text") / std::string(mEventScriptPath + ".txt"));
120120

@@ -130,7 +130,7 @@ void LEventDataDOMNode::SaveEventArchive(){
130130

131131
if(msgFile != nullptr){
132132
msgFile->SetData((uint8_t*)msgFileData.data(), msgFileData.size());
133-
} else {
133+
} else if(createIfNotExist){
134134
msgFile = Archive::File::Create();
135135
msgFile->SetName(std::string(mEventMessagePath + ".csv"));
136136
msgFile->SetData((uint8_t*)msgFileData.data(), msgFileData.size());
@@ -146,7 +146,7 @@ void LEventDataDOMNode::SaveEventArchive(){
146146

147147
if(txtFile != nullptr){
148148
txtFile->SetData((uint8_t*)txtFileData.data(), txtFileData.size());
149-
} else {
149+
} else if(createIfNotExist){
150150
txtFile = Archive::File::Create();
151151
txtFile->SetName(std::string(mEventScriptPath + ".txt"));
152152
txtFile->SetData((uint8_t*)txtFileData.data(), txtFileData.size());

src/DOM/MapDOMNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ bool LMapDOMNode::SaveMapToArchive(std::filesystem::path file_path)
443443
if(std::filesystem::exists(eventPath))
444444
{
445445
for(auto event : GetChildrenOfType<LEventDataDOMNode>(EDOMNodeType::EventData)){
446-
event->SaveEventArchive();
446+
event->SaveEventArchive(false);
447447
}
448448
}
449449

src/DOM/RoomDOMNode.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
#include "IconsForkAwesome.h"
1010
#include "modes/ActorMode.hpp"
1111
#include "scene/ModelViewer.hpp"
12+
#include "io/BtiIO.hpp"
13+
#include "ResUtil.hpp"
1214

1315
namespace {
1416
std::shared_ptr<Archive::Rarc> ActiveRoomArchive = nullptr;
1517
std::shared_ptr<Archive::File> EditFileName = nullptr;
1618
std::shared_ptr<Archive::File> SelectedFile = nullptr;
1719
std::shared_ptr<Archive::File> SelectedAnimation = nullptr;
1820
std::string FileName = "(null)";
21+
uint32_t PreviousRoomID = 0xFFFFFFFF;
22+
uint32_t CurRoomNameImgID = 0x00000000;
23+
uint32_t CurRoomNameWidth = 0;
1924
}
2025

2126
std::string const LRoomEntityTreeNodeNames[LRoomEntityType_Max] = {
@@ -168,6 +173,25 @@ void LRoomDOMNode::RenderHierarchyUI(std::shared_ptr<LDOMNodeBase> self, LEditor
168173

169174
bool openRoomRes = false;
170175
if(GetIsSelected()){
176+
if(PreviousRoomID != mRoomNumber && GCResourceManager.mLoadedGameArchive){
177+
PreviousRoomID = mRoomNumber;
178+
179+
if(CurRoomNameImgID != 0){
180+
glDeleteTextures(1, &CurRoomNameImgID);
181+
}
182+
std::cout << std::format("/kawano/roomname/{}", LResUtility::GetNameMap("MapTitlecards")["titlecards"][mRoomNumber].get<std::string>()) << std::endl;
183+
auto fileData = GCResourceManager.mGameArchive->GetFile(std::format("/kawano/roomname/{}", LResUtility::GetNameMap("MapTitlecards")["titlecards"][mRoomNumber].get<std::string>()));
184+
bStream::CMemoryStream file(fileData->GetData(), fileData->GetSize(), bStream::Endianess::Big, bStream::OpenMode::In);
185+
186+
uint32_t h;
187+
uint8_t* roomImage = Bti::DecodeImage(&file, CurRoomNameWidth, h);
188+
189+
glCreateTextures(GL_TEXTURE_2D, 1, &CurRoomNameImgID);
190+
glTextureStorage2D(CurRoomNameImgID, 1, GL_RGBA8, CurRoomNameWidth, h);
191+
glTextureSubImage2D(CurRoomNameImgID, 0, 0, 0, CurRoomNameWidth, h, GL_RGBA, GL_UNSIGNED_BYTE, roomImage);
192+
delete[] roomImage;
193+
194+
}
171195
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
172196
ImGui::SetNextWindowPos(center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
173197
if(ImGui::BeginPopupModal("##roomResources", NULL, ImGuiWindowFlags_AlwaysAutoResize)){
@@ -619,6 +643,13 @@ void LRoomDOMNode::RenderDetailsUI(float dt)
619643
{
620644
std::shared_ptr<LRoomDataDOMNode> dataNode = GetChildrenOfType<LRoomDataDOMNode>(EDOMNodeType::RoomData)[0];
621645

646+
ImGui::Image(static_cast<uintptr_t>(CurRoomNameImgID), ImVec2(CurRoomNameWidth, 32));
647+
ImGui::SameLine();
648+
ImGui::Text(ICON_FK_FOLDER_OPEN);
649+
if(ImGui::IsItemClicked()){
650+
// open file
651+
}
652+
622653
// Integers
623654
ImGui::InputInt("Lightning Direction", &mThunder);
624655
LUIUtility::RenderTooltip("How frequently thunder and lightning occurs while in this room.");

0 commit comments

Comments
 (0)