Skip to content

Commit

Permalink
Code update, native iOS interface. async loading of archives as "pres…
Browse files Browse the repository at this point in the history
…et bundles", save preset ratings, save preset history

IMGUI update
  • Loading branch information
Icer committed Jul 1, 2021
1 parent 65ff6ed commit 1b3d8c4
Show file tree
Hide file tree
Showing 101 changed files with 11,946 additions and 2,252 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()


set(CMAKE_VERBOSE_MAKEFILE on)
#set(CMAKE_VERBOSE_MAKEFILE on)

set(COMMON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(APP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/app)
Expand Down Expand Up @@ -103,6 +103,7 @@ set(MDP_SOURCE
${COMMON_SOURCE_DIR}/ArchiveReader.cpp
${COMMON_SOURCE_DIR}/ImageReader.cpp
${COMMON_SOURCE_DIR}/ImageWriter.cpp
${COMMON_SOURCE_DIR}/PresetBundle.cpp
${COMMON_SOURCE_DIR}/VizController.cpp
${COMMON_SOURCE_DIR}/TProfiler.cpp
${COMMON_SOURCE_DIR}/imgui_support.cpp
Expand All @@ -111,7 +112,6 @@ set(MDP_SOURCE
${COMMON_SOURCE_DIR}/vis_milk2/plugin.cpp
${COMMON_SOURCE_DIR}/vis_milk2/state.cpp
${COMMON_SOURCE_DIR}/vis_milk2/AudioAnalyzer.cpp
${COMMON_SOURCE_DIR}/audio/RawFileAudioSource.cpp
${COMMON_SOURCE_DIR}/audio/WavFileAudioSource.cpp
${COMMON_SOURCE_DIR}/audio/NullAudioSource.cpp
${COMMON_SOURCE_DIR}/render/context.cpp
Expand Down
191 changes: 110 additions & 81 deletions Milkdrop.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/CommonApple/CommonApple.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
bool GetResourceDir(std::string &outdir);
bool GetApplicationSupportDir(std::string &outdir);

std::string AppGetShortVersionString();
std::string AppGetBuildVersionString();
13 changes: 13 additions & 0 deletions app/CommonApple/CommonApple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ bool GetApplicationSupportDir(std::string &outdir)
return true;
}

std::string AppGetShortVersionString()
{
NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
return version.UTF8String;
}

std::string AppGetBuildVersionString()
{
NSString * build = [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
if (!build) return "0";
return build.UTF8String;
}

39 changes: 0 additions & 39 deletions app/CommonApple/Visualizer.h

This file was deleted.

65 changes: 0 additions & 65 deletions app/CommonApple/Visualizer.mm

This file was deleted.

Binary file added app/MilkdropAppLaunch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions app/OSX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 icer. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSMicrophoneUsageDescription</key>
Expand Down
7 changes: 1 addition & 6 deletions app/OSX/RenderViewControllerOSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
#import <Cocoa/Cocoa.h>
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#import "../CommonApple/Visualizer.h"
#include "render/context_metal.h"
#import "IVizController.h"
#import "MetalView.h"
#import "GLView.h"

// Our macOS view controller.
@interface RenderViewControllerOSX : NSViewController <MTKViewDelegate, GLViewDelegate, EventDelegate>

@property (strong, nonatomic) IBOutlet id<RenderViewDelegate> _Nullable visualizer;


@end
63 changes: 46 additions & 17 deletions app/OSX/RenderViewControllerOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#import "RenderViewControllerOSX.h"

#include "IVizController.h"
#include "VizController.h"
#include "render/context.h"
#include "render/context_metal.h"
#include "render/context_gles.h"
Expand All @@ -17,6 +19,18 @@
#include "TProfiler.h"
#include "platform.h"

#include "keycode.h"


struct KeyEvent
{
char c;
KeyCode code;
bool KeyShift;
bool KeyCtrl;
bool KeyAlt;
bool KeyCommand;
};


static KeyEvent ConvertKeyEvent(NSEvent *event)
Expand All @@ -39,6 +53,7 @@ @implementation RenderViewControllerOSX
render::ContextPtr _gl_context;
render::metal::IMetalContextPtr _metal_context;
NSTrackingArea *_trackingArea;
IVizControllerPtr _vizController;
}


Expand Down Expand Up @@ -89,7 +104,7 @@ - (void)keyUp:(NSEvent *)event

-(void)onDragDrop:(NSArray * _Nonnull)files
{
[self.visualizer onDragDrop:files];
// [self.visualizer onDragDrop:files];
}


Expand Down Expand Up @@ -143,8 +158,15 @@ - (void)viewDidLoad
[self initGL];
}

self.visualizer = [[Visualizer alloc] initWithContext:_context];



std::string resourceDir;
GetResourceDir(resourceDir);
std::string assetDir = PathCombine(resourceDir, "assets");
std::string userDir;
GetApplicationSupportDir(userDir);
_vizController = CreateVizController(_context, assetDir, userDir);


ImGui_ImplOSX_Init();

Expand Down Expand Up @@ -296,13 +318,17 @@ - (void)drawInGLView:(GLView * _Nonnull)view
);

// _context->SetView( _view );
[self.visualizer draw:0 screenCount:1];

if (self.visualizer.shouldQuit)
{
NSWindow *window = view.window;
[window close];
}
_context->BeginScene();
_vizController->Render(0, 1);
_context->EndScene();
_context->Present();


// if (_vizController->ShouldQuit())
// {
// NSWindow *window = view.window;
// [window close];
// }
}
}

Expand All @@ -325,14 +351,17 @@ - (void)drawInMTKView:(nonnull MTKView *)view
//

_metal_context->SetView( view );
[self.visualizer draw:0 screenCount:1];

_context->BeginScene();
_vizController->Render(0, 1);
_context->EndScene();
_context->Present();


if (self.visualizer.shouldQuit)
{
NSWindow *window = view.window;
[window close];
}
// if (_vizController->ShouldQuit())
// {
// NSWindow *window = view.window;
// [window close];
// }
}
}

Expand Down
33 changes: 14 additions & 19 deletions app/Win32/MilkDropRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "VizController.h"
#include "../external/imgui/imgui.h"
#include "../external/imgui/imgui_impl_win32.h"
#include "../external/imgui/backends/imgui_impl_win32.h"

#include "imgui_support.h"

Expand Down Expand Up @@ -205,14 +205,16 @@ LRESULT DXWindow::WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lPa
bool down = (uMsg == WM_KEYDOWN);
int modifiers = HIWORD(lParam);

KeyEvent e;
e.c = (char)wParam;
e.code = ConvertKeyCode_Win32((int)wParam );
ImGuiIO& io = ImGui::GetIO();

//e.c = (char)wParam;
auto code = ConvertKeyCode_Win32((int)wParam );

e.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
e.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
e.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
e.KeyCommand = (::GetKeyState(VK_LWIN) & 0x8000) != 0;
io.KeysDown[code] = down;
io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
//io.Key = (::GetKeyState(VK_LWIN) & 0x8000) != 0;

/*
e.KeyCtrl = modifiers & MOD_CONTROL;
Expand All @@ -221,15 +223,8 @@ LRESULT DXWindow::WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lPa
e.KeyShift = modifiers & MOD_SHIFT;
*/

ImGuiIO& io = ImGui::GetIO();


if (m_controller)
{
if (down)
m_controller->OnKeyDown(e);
else
m_controller->OnKeyUp(e);
}
break;
}

Expand Down Expand Up @@ -296,11 +291,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,

#if DEBUG
//_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_EVERY_128_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_EVERY_128_DF | _CRTDBG_LEAK_CHECK_DF);
// _CrtSetBreakAlloc(8488);
#endif

::SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
// ::SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
RedirectIOToConsole();

// create app window
Expand All @@ -313,7 +308,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,

ContextPtr context;

#if 0
#if 1
context = render::d3d9::D3D9CreateContext(hwnd);
#else
context = render::d3d11::D3D11CreateContext(hwnd);
Expand Down
2 changes: 1 addition & 1 deletion app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

Expand Down
Loading

0 comments on commit 1b3d8c4

Please sign in to comment.