mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 13:15:45 -04:00
Move shared frontend code from SDL to a seperate project
This commit is contained in:
@ -1,15 +1,9 @@
|
||||
add_executable(duckstation-sdl
|
||||
icon.cpp
|
||||
icon.h
|
||||
imgui_impl_sdl.cpp
|
||||
imgui_impl_sdl.h
|
||||
imgui_styles.cpp
|
||||
imgui_styles.h
|
||||
main.cpp
|
||||
opengl_host_display.cpp
|
||||
opengl_host_display.h
|
||||
sdl_audio_stream.cpp
|
||||
sdl_audio_stream.h
|
||||
sdl_host_interface.cpp
|
||||
sdl_host_interface.h
|
||||
sdl_settings_interface.cpp
|
||||
@ -17,7 +11,7 @@ add_executable(duckstation-sdl
|
||||
)
|
||||
|
||||
target_include_directories(duckstation-sdl PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(duckstation-sdl PRIVATE core common imgui nativefiledialog glad simpleini ${SDL2_LIBRARIES})
|
||||
target_link_libraries(duckstation-sdl PRIVATE core common imgui nativefiledialog glad simpleini frontend-common ${SDL2_LIBRARIES})
|
||||
|
||||
if(WIN32)
|
||||
target_sources(duckstation-sdl PRIVATE
|
||||
@ -26,3 +20,4 @@ if(WIN32)
|
||||
)
|
||||
target_link_libraries(duckstation-sdl PRIVATE d3d11.lib dxgi.lib winmm.lib ${SDL2MAIN_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
@ -47,14 +47,14 @@
|
||||
<ProjectReference Include="..\core\core.vcxproj">
|
||||
<Project>{868b98c8-65a1-494b-8346-250a73a48c0a}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\frontend-common\frontend-common.vcxproj">
|
||||
<Project>{6245dec8-d2da-47ee-a373-cbd6fcf3ece6}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="d3d11_host_display.cpp" />
|
||||
<ClCompile Include="imgui_impl_sdl.cpp" />
|
||||
<ClCompile Include="imgui_styles.cpp" />
|
||||
<ClCompile Include="opengl_host_display.cpp" />
|
||||
<ClCompile Include="icon.cpp" />
|
||||
<ClCompile Include="sdl_audio_stream.cpp" />
|
||||
<ClCompile Include="sdl_host_interface.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="sdl_settings_interface.cpp" />
|
||||
@ -62,10 +62,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="d3d11_host_display.h" />
|
||||
<ClInclude Include="imgui_impl_sdl.h" />
|
||||
<ClInclude Include="imgui_styles.h" />
|
||||
<ClInclude Include="opengl_host_display.h" />
|
||||
<ClInclude Include="icon.h" />
|
||||
<ClInclude Include="sdl_audio_stream.h" />
|
||||
<ClInclude Include="sdl_host_interface.h" />
|
||||
<ClInclude Include="sdl_settings_interface.h" />
|
||||
</ItemGroup>
|
||||
@ -392,4 +389,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -2,22 +2,16 @@
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="sdl_audio_stream.cpp" />
|
||||
<ClCompile Include="icon.cpp" />
|
||||
<ClCompile Include="opengl_host_display.cpp" />
|
||||
<ClCompile Include="sdl_host_interface.cpp" />
|
||||
<ClCompile Include="d3d11_host_display.cpp" />
|
||||
<ClCompile Include="imgui_styles.cpp" />
|
||||
<ClCompile Include="sdl_settings_interface.cpp" />
|
||||
<ClCompile Include="imgui_impl_sdl.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="icon.h" />
|
||||
<ClInclude Include="sdl_audio_stream.h" />
|
||||
<ClInclude Include="opengl_host_display.h" />
|
||||
<ClInclude Include="sdl_host_interface.h" />
|
||||
<ClInclude Include="d3d11_host_display.h" />
|
||||
<ClInclude Include="imgui_styles.h" />
|
||||
<ClInclude Include="sdl_settings_interface.h" />
|
||||
<ClInclude Include="imgui_impl_sdl.h" />
|
||||
</ItemGroup>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
constexpr int WINDOW_ICON_WIDTH = 64;
|
||||
constexpr int WINDOW_ICON_HEIGHT = 64;
|
||||
extern unsigned int WINDOW_ICON_DATA[WINDOW_ICON_WIDTH * WINDOW_ICON_HEIGHT];
|
||||
|
||||
constexpr int APP_ICON_WIDTH = 260;
|
||||
constexpr int APP_ICON_HEIGHT = 260;
|
||||
extern unsigned int APP_ICON_DATA[APP_ICON_WIDTH * APP_ICON_HEIGHT];
|
@ -1,66 +0,0 @@
|
||||
#include "imgui_styles.h"
|
||||
|
||||
void ImGui::StyleColorsDarker(ImGuiStyle* dst)
|
||||
{
|
||||
ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
|
||||
ImVec4* colors = style->Colors;
|
||||
|
||||
colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f);
|
||||
colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
|
||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
|
||||
colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f);
|
||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f);
|
||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
||||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f);
|
||||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f);
|
||||
colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.33f, 0.38f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_ButtonActive] = ImVec4(0.27f, 0.32f, 0.38f, 1.00f);
|
||||
colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f);
|
||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.33f, 0.38f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.27f, 0.32f, 0.38f, 1.00f);
|
||||
colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.33f, 0.38f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.27f, 0.32f, 0.38f, 1.00f);
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.33f, 0.38f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.27f, 0.32f, 0.38f, 1.00f);
|
||||
colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||
colors[ImGuiCol_TabHovered] = ImVec4(0.33f, 0.38f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_TabActive] = ImVec4(0.27f, 0.32f, 0.38f, 1.00f);
|
||||
colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||
colors[ImGuiCol_DockingPreview] = ImVec4(0.26f, 0.59f, 0.98f, 0.70f);
|
||||
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
|
||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
|
||||
}
|
||||
|
||||
#include "font_roboto_regular.inl"
|
||||
|
||||
void ImGui::AddRobotoRegularFont(float size /*= 15.0f*/)
|
||||
{
|
||||
ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(s_font_roboto_regular_compressed_data,
|
||||
s_font_roboto_regular_compressed_size, size);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
#include <imgui.h>
|
||||
|
||||
namespace ImGui {
|
||||
void StyleColorsDarker(ImGuiStyle* dst = nullptr);
|
||||
void AddRobotoRegularFont(float size = 15.0f);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
#include "sdl_audio_stream.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/log.h"
|
||||
#include <SDL.h>
|
||||
Log_SetChannel(SDLAudioStream);
|
||||
|
||||
SDLAudioStream::SDLAudioStream() = default;
|
||||
|
||||
SDLAudioStream::~SDLAudioStream()
|
||||
{
|
||||
if (m_is_open)
|
||||
SDLAudioStream::CloseDevice();
|
||||
}
|
||||
|
||||
bool SDLAudioStream::OpenDevice()
|
||||
{
|
||||
DebugAssert(!m_is_open);
|
||||
|
||||
SDL_AudioSpec spec = {};
|
||||
spec.freq = m_output_sample_rate;
|
||||
spec.channels = static_cast<Uint8>(m_channels);
|
||||
spec.format = AUDIO_S16;
|
||||
spec.samples = static_cast<Uint16>(m_buffer_size);
|
||||
spec.callback = AudioCallback;
|
||||
spec.userdata = static_cast<void*>(this);
|
||||
|
||||
SDL_AudioSpec obtained = {};
|
||||
if (SDL_OpenAudio(&spec, &obtained) < 0)
|
||||
{
|
||||
Log_ErrorPrintf("SDL_OpenAudio failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_is_open = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDLAudioStream::PauseDevice(bool paused)
|
||||
{
|
||||
SDL_PauseAudio(paused ? 1 : 0);
|
||||
}
|
||||
|
||||
void SDLAudioStream::CloseDevice()
|
||||
{
|
||||
DebugAssert(m_is_open);
|
||||
SDL_CloseAudio();
|
||||
m_is_open = false;
|
||||
}
|
||||
|
||||
void SDLAudioStream::AudioCallback(void* userdata, uint8_t* stream, int len)
|
||||
{
|
||||
SDLAudioStream* const this_ptr = static_cast<SDLAudioStream*>(userdata);
|
||||
const u32 num_samples = len / sizeof(SampleType) / this_ptr->m_channels;
|
||||
const u32 read_samples = this_ptr->ReadSamples(reinterpret_cast<SampleType*>(stream), num_samples);
|
||||
const u32 silence_samples = num_samples - read_samples;
|
||||
if (silence_samples > 0)
|
||||
{
|
||||
std::memset(reinterpret_cast<SampleType*>(stream) + (read_samples * this_ptr->m_channels), 0,
|
||||
silence_samples * this_ptr->m_channels * sizeof(SampleType));
|
||||
}
|
||||
}
|
||||
|
||||
void SDLAudioStream::BufferAvailable() {}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include "common/audio_stream.h"
|
||||
#include <cstdint>
|
||||
|
||||
class SDLAudioStream final : public AudioStream
|
||||
{
|
||||
public:
|
||||
SDLAudioStream();
|
||||
~SDLAudioStream();
|
||||
|
||||
protected:
|
||||
bool OpenDevice() override;
|
||||
void PauseDevice(bool paused) override;
|
||||
void CloseDevice() override;
|
||||
void BufferAvailable() override;
|
||||
|
||||
static void AudioCallback(void* userdata, uint8_t* stream, int len);
|
||||
|
||||
bool m_is_open = false;
|
||||
};
|
@ -7,11 +7,11 @@
|
||||
#include "core/gpu.h"
|
||||
#include "core/host_display.h"
|
||||
#include "core/system.h"
|
||||
#include "icon.h"
|
||||
#include "imgui_impl_sdl.h"
|
||||
#include "imgui_styles.h"
|
||||
#include "frontend-common/icon.h"
|
||||
#include "frontend-common/imgui_styles.h"
|
||||
#include "frontend-common/sdl_audio_stream.h"
|
||||
#include "opengl_host_display.h"
|
||||
#include "sdl_audio_stream.h"
|
||||
#include "sdl_settings_interface.h"
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
|
Reference in New Issue
Block a user