Skip to content

Commit

Permalink
Great means not good
Browse files Browse the repository at this point in the history
  • Loading branch information
telecomadm1145 committed Aug 8, 2024
1 parent 7693ac4 commit 6497e7b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CasioEmuMsvc/CasioEmuMsvc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
<ClCompile Include="Gui\Hooks.cpp" />
<ClCompile Include="Gui\imgui\imgui_demo.cpp" />
<ClCompile Include="Peripheral\ROMWindow.cpp" />
<ClCompile Include="StartupUi\Editor.cpp" />
<ClCompile Include="StartupUi\StartupUi.cpp" />
<ClCompile Include="Gui\CasioData.cpp" />
<ClCompile Include="Gui\CodeViewer.cpp" />
Expand Down Expand Up @@ -389,6 +390,7 @@
<ClInclude Include="Gui\LabelViewer.h" />
<ClInclude Include="Gui\MemBreakPoint.hpp" />
<ClInclude Include="Gui\HwController.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stringhelper.h" />
<ClInclude Include="Gui\Ui.hpp" />
<ClInclude Include="Gui\WatchWindow.hpp" />
Expand Down Expand Up @@ -422,6 +424,12 @@
<None Include=".clang-format" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\sdl2_image.nuget.redist.2.8.2\build\native\sdl2_image.nuget.redist.targets" Condition="Exists('..\packages\sdl2_image.nuget.redist.2.8.2\build\native\sdl2_image.nuget.redist.targets')" />
Expand Down
16 changes: 16 additions & 0 deletions CasioEmuMsvc/CasioEmuMsvc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
<ClCompile Include="Gui\imgui\imgui_demo.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="StartupUi\Editor.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Config.hpp">
Expand Down Expand Up @@ -356,9 +359,22 @@
<ClInclude Include="Containers\ConcurrentObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include=".clang-format" />
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions CasioEmuMsvc/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
// 1 - English
// 2 - Chinese

// #define LANGUAGE 1
#define LANGUAGE 2
#define LANGUAGE 1
//#define LANGUAGE 2

#define LOCK(x) \
std::lock_guard<std::mutex> lock_##x{x};
Binary file added CasioEmuMsvc/Resource.rc
Binary file not shown.
Empty file.
20 changes: 11 additions & 9 deletions CasioEmuMsvc/casioemu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,30 @@ int main(int argc, char* argv[]) {

bool guiCreated = false;
auto frame_event = SDL_RegisterEvents(1);
bool busy = false;
std::thread t3([&]() {
SDL_Event se{};
se.type = frame_event;
se.user.windowID = SDL_GetWindowID(emulator.window);
while (1) {
SDL_PushEvent(&se);
SDL_Delay(25);
if (!busy)
SDL_PushEvent(&se);
SDL_Delay(24);
}
});
t3.detach();
test_gui(&guiCreated);
while (emulator.Running()) {
SDL_Event event{};
busy = false;
if (!SDL_PollEvent(&event))
continue;
busy = true;
if (event.type == frame_event) {
gui_loop();
emulator.Frame();
continue;
}
if ((SDL_GetKeyboardFocus() != emulator.window) && guiCreated) {
ImGui_ImplSDL2_ProcessEvent(&event);
continue;
}
switch (event.type) {
case SDL_WINDOWEVENT:
switch (event.window.event) {
Expand All @@ -135,9 +135,6 @@ int main(int argc, char* argv[]) {
std::exit(0);
break;
case SDL_WINDOWEVENT_RESIZED:
if (event.window.windowID == SDL_GetWindowID(emulator.window)) {
emulator.WindowResize(event.window.data1, event.window.data2);
}
break;
}
break;
Expand All @@ -148,6 +145,11 @@ int main(int argc, char* argv[]) {
case SDL_TEXTINPUT:
case SDL_MOUSEMOTION:
case SDL_MOUSEWHEEL:
default:
if ((SDL_GetKeyboardFocus() != emulator.window) && guiCreated) {
ImGui_ImplSDL2_ProcessEvent(&event);
continue;
}
emulator.UIEvent(event);
break;
}
Expand Down
Binary file added CasioEmuMsvc/icon.ico
Binary file not shown.
16 changes: 16 additions & 0 deletions CasioEmuMsvc/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Resource.rc 使用
//
#define IDI_ICON1 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

0 comments on commit 6497e7b

Please sign in to comment.