Skip to content

Commit

Permalink
Merge pull request #11 from Jayveer/feature/native-gui
Browse files Browse the repository at this point in the history
Feature/native gui
  • Loading branch information
Jayveer authored Aug 9, 2020
2 parents b6c5cab + 2e29a51 commit 5bd718c
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 47 deletions.
2 changes: 1 addition & 1 deletion DecimaExplorer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ END

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "E:\\Art\\dex.ico"
IDI_ICON1 ICON "dex.ico"

#endif // English (United Kingdom) resources
/////////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 14 additions & 2 deletions DecimaExplorer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gui\draw\component\MenuComponent\MenuComponent.cpp">
<ClCompile Include="gui\draw\component\menu\MenuComponent.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gui\draw\component\progress\ProgressComponent.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -341,7 +347,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (GUI)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (GUI)|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gui\draw\component\MenuComponent\MenuComponent.h">
<ClInclude Include="gui\draw\component\menu\MenuComponent.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gui\draw\component\progress\ProgressComponent.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down
16 changes: 11 additions & 5 deletions DecimaExplorer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@
<ClCompile Include="gui\draw\component\list\ListComponent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="gui\draw\component\MenuComponent\MenuComponent.cpp">
<ClCompile Include="main_gui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main_gui.cpp">
<ClCompile Include="gui\draw\component\menu\MenuComponent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="gui\draw\component\progress\ProgressComponent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -161,15 +164,18 @@
<ClInclude Include="utils\Numutils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\draw\component\MenuComponent\MenuComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\GUI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\draw\component\menu\MenuComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gui\draw\component\progress\ProgressComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ooz\LICENSE.md" />
Expand Down
4 changes: 4 additions & 0 deletions DecimaExplorer.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release (GUI)|Win32'">
<LocalDebuggerCommandArguments>-extract "G:\Games\PC\steamapps\common\Death Stranding\data" \ds\models\item\ludk_ludenskeyring\core\ludk_main_big\model\parts\mesh_main_lx</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion cli/CLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CLI::directoryExtract(char* arg) {
if (found) break;
}

found ? printf("Finished extracting file %s\n", output) : printf("Failed to find file %s\n", output);
found ? printf("Finished extracting file %s\n", output.c_str()) : printf("Failed to find file %s\n", output.c_str());
}

void CLI::list() {
Expand Down
1 change: 1 addition & 0 deletions decima/file/prefetch/CorePrefetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ class CorePrefetch: public DecimaCore {

void extractFileTable();
void extractFileTableStreamed(DataBuffer data);
DecimaPrefetch* getPrefetch() { return &this->prefetch; }
};
Binary file added dex.ico
Binary file not shown.
58 changes: 26 additions & 32 deletions gui/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

GUI::GUI(HINSTANCE hInst) {
mainWindow.create(hInst, this, NULL, 0xD3D3D3);
SetWindowText(mainWindow.getHandle(), "test");
browseButton.setCaller(this);
browserView.setCaller(this);
fileList.setCaller(this);
Expand Down Expand Up @@ -42,8 +41,6 @@ void GUI::viewDrawing(HWND hwnd) {}

void GUI::buttonDrawing(HWND hwnd) {}



void GUI::resetData() {
if (sbuf) {
delete sbuf;
Expand All @@ -59,7 +56,6 @@ void GUI::resetData() {
fileList.setHandle(NULL);

prefetchData.clear();
currentPos = 0;
}

void GUI::directoryChosen(std::string directory) {
Expand All @@ -83,21 +79,22 @@ void GUI::directoryChosen(std::string directory) {

prefetchStream = new std::istream(sbuf);
prefetchStream->seekg(0x1C, SEEK_CUR);
prefetchStream->read((char*)&prefetchSize, 4);

addFilesToRows();
}

void GUI::saveDirectoryChosen(std::string directory) {
int pos = -1;

ProgressComponent pc;
pc.create(mainWindow.getHandle(), { 1280, 35 }, { 0, 647 });
pc.setRange(fileList.getNumSelected());
pc.setIncrement();
do {
char file[MAX_PATH];
pos = ListView_GetNextItem(fileList.getHandle(), pos, LVNI_SELECTED);
if (pos == -1) break;
ListView_GetItemText(fileList.getHandle(), pos, 0, file, MAX_PATH);
directoryExtract(file, directory);

pc.increment();
} while (pos != -1);

MessageBox(mainWindow.getHandle(), "Selected files extracted successfully", "Done", MB_OK);
Expand All @@ -122,44 +119,41 @@ void GUI::directoryExtract(std::string filename, std::string output) {

}

bool GUI::reachedEnd() {
return (prefetchSize - currentPos) <= 0;
}

void GUI::addFilesToRows() {
int left = (prefetchSize - currentPos);
int remainder = prefetchSize % 1000;
int size = left == remainder ? remainder : 1000;
SendMessage(fileList.getHandle(), WM_SETREDRAW, FALSE, 0);

uint32_t prefetchSize;
prefetchStream->read((char*)&prefetchSize, 4);

for (int i = 0; i < size; i++) {
for (int i = 0; i < prefetchSize; i++) {
uint32_t size, hash;
prefetchStream->read((char*)&size, 4);
prefetchStream->read((char*)&hash, 4);
std::string str;
str.resize(size);
prefetchStream->read((char*)str.c_str(), size);
fileList.createItem(currentPos, str.c_str());
//fileList.createSubItem(currentPos, 1, "TODO");
currentPos++;
fileList.createItem(i, str.c_str());
}

if (reachedEnd()) {
delete prefetchStream;
prefetchStream = NULL;
delete sbuf;
sbuf = NULL;
uint32_t numSizes;
prefetchStream->read((char*)&numSizes, 4);

for (int i = 0; i < numSizes; i++) {
uint32_t size;
prefetchStream->read((char*)&size, 4);
std::string fsize = std::to_string(byteToKiloByte(size)) + " KB";
fileList.createSubItem(i, 1, fsize.c_str());
}

SendMessage(fileList.getHandle(), WM_SETREDRAW, TRUE, 0);

delete prefetchStream;
prefetchStream = NULL;
delete sbuf;
sbuf = NULL;
}

void GUI::listScrolled(HWND hwnd) {
SCROLLINFO si = { sizeof(si), SIF_ALL };
GetScrollInfo(fileList.getHandle(), SB_VERT, &si);
bool hitBottom = (si.nPos + si.nPage) == (UINT)si.nMax + 1;
if (hitBottom) {
if (!reachedEnd()) addFilesToRows();
}
}
void GUI::listScrolled(HWND hwnd) { }

void GUI::buttonPressed(HWND hwnd) {
FileComponent fc;
Expand Down
7 changes: 2 additions & 5 deletions gui/GUI.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include "draw/MainWindow.h"

#include "../decima/file/prefetch/CorePrefetch.h"
#include "../decima/archive/mpk/ArchiveMoviePack.h"
#include "../decima/archive/bin/initial/BinInitial.h"
#include "../utils/NumUtils.h"

#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
Expand All @@ -20,7 +20,7 @@ class GUI : public ButtonCaller, WindowCaller, ViewCaller, TextfieldCaller, List
ButtonComponent extractButton;
ViewComponent footerView;

const char* aboutText = "Created by Jayveer\n https://github.com/Jayveer/Decima-Explorer \n\nSpecial Thanks for work on decryption.\n Ekey https://github.com/Ekey \n Wunkolo https://github.com/wunkolo \n\nLibraries:\n Ooz By Powzix https://github.com/powzix/ooz \n Murmur3 by Peter Scott https://github.com/PeterScott/murmur3 \n MD5 by Aladdin Enterprises";
const char* aboutText = "Decima Explorer is a free and open source program. If you paid for this program demand your money back from the seller.\n\n Created by Jayveer\n https://github.com/Jayveer/Decima-Explorer \n\nSpecial Thanks for work on decryption.\n Ekey https://github.com/Ekey \n Wunkolo https://github.com/wunkolo \n\nLibraries:\n Ooz By Powzix https://github.com/powzix/ooz \n Murmur3 by Peter Scott https://github.com/PeterScott/murmur3 \n MD5 by Aladdin Enterprises";

void initExtractButton(HWND parent);
void initBrowseButton(HWND parent);
Expand Down Expand Up @@ -50,9 +50,6 @@ class GUI : public ButtonCaller, WindowCaller, ViewCaller, TextfieldCaller, List
DataBuffer prefetchData;
membuf *sbuf;
std::istream *prefetchStream;
std::istream* prefetchSizeStream;
int prefetchSize;
int currentPos = 0;
public:
GUI(HINSTANCE hInst);
~GUI();
Expand Down
5 changes: 5 additions & 0 deletions gui/draw/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ LRESULT MainWindow::ProcedureWrapper(HWND inHwnd, UINT message, WPARAM wParam, L
if (listview && nm->code == LVN_ENDSCROLL) listview->scrolled();
}
}break;
case WM_KEYDOWN: {
if (wParam == 'A' && GetKeyState(VK_CONTROL) < 0) {
int dummy = 0;
}
} break;
case WM_CLOSE: {
DestroyWindow(inHwnd);
} break;
Expand Down
2 changes: 1 addition & 1 deletion gui/draw/MainWindow.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once
#include "component/textfield/TextFieldComponent.h"
#include "component/progress/ProgressComponent.h"
#include "component/window/WindowComponent.h"
#include "component/button/ButtonComponent.h"
#include "component/image/ImageComponent.h"
#include "component/view/ViewComponent.h"
#include "component/file/FileComponent.h"
#include "component/list/ListComponent.h"
#include "component/MenuComponent/MenuComponent.h"

class MainWindow : public ProcedureCaller {
private:
Expand Down
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions gui/draw/component/progress/ProgressComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "ProgressComponent.h"

ProgressComponent::ProgressComponent() {

}

ProgressComponent::~ProgressComponent() {

}

void ProgressComponent::create(HWND parent, Dimensions dimensions, Origin origin) {
DWORD style = WS_CHILD | WS_VISIBLE;
HWND hwnd = CreateWindow(PROGRESS_CLASS, "Loading file", style, origin.x, origin.y, dimensions.width, dimensions.height, parent, NULL, NULL, this);
setHandle(hwnd);
}

void ProgressComponent::setRange(int maxRange) {
SendMessage(getHandle(), PBM_SETRANGE, 0, MAKELPARAM(0, maxRange));
}

void ProgressComponent::setIncrement() {
SendMessage(getHandle(), PBM_SETSTEP, (WPARAM)1, 0);
}

void ProgressComponent::increment() {
SendMessage(getHandle(), PBM_STEPIT, 0, 0);
}
14 changes: 14 additions & 0 deletions gui/draw/component/progress/ProgressComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#include "../Component.h"

class ProgressComponent : Component {
public:
ProgressComponent();
~ProgressComponent();

void create(HWND parent, Dimensions dimensions, Origin origin);
void setRange(int maxRange);
void setIncrement();
void increment();

};
7 changes: 7 additions & 0 deletions utils/Numutils.h
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#pragma once
#include <string>
#include <math.h>

inline
int byteToKiloByte(int bytes) {
return bytes % 1024 ? (bytes / 1024) + 1 : bytes / 1024;
}

0 comments on commit 5bd718c

Please sign in to comment.