Browse Source

AspectRatio: UWP UI

Pal Lockheart 6 years ago
parent
commit
6ffd00883b
3 changed files with 14 additions and 0 deletions
  1. 4 0
      winrt/SDLPal.Common/MainPage.xaml
  2. 8 0
      winrt/SDLPal.Common/MainPage.xaml.cpp
  3. 2 0
      winrt/pal_config.h

+ 4 - 0
winrt/SDLPal.Common/MainPage.xaml

@@ -47,6 +47,10 @@
                 </Grid>
                 <ToggleSwitch x:Name="tsTouchOverlay" x:Uid="TouchOverlay" Header="启用触屏辅助" OffContent="否" OnContent="是" />
                 <ToggleSwitch x:Name="tsKeepAspect" x:Uid="AspectRatio" Header="保持纵横比" OffContent="否" OnContent="是" />
+                <ComboBox x:Name="cbAspectRatio" x:Uid="Ratio" HorizontalAlignment="Stretch" Header="纵横比" PlaceholderText="选择纵横比">
+                    <ComboBoxItem Content="16:10"/>
+                    <ComboBoxItem Content="4:3"/>
+                </ComboBox>
                 <ToggleSwitch x:Name="tsEnableAVI" x:Uid="EnableAVI" Header="启用 AVI 过场动画" OffContent="否" OnContent="是" />
                 <ToggleSwitch x:Name="tsStereo" x:Uid="Stereo" Header="立体声" OffContent="否" OnContent="是" />
                 <Slider x:Name="slMusicVolume" x:Uid="MusicVolume" Header="音乐音量" TickPlacement="Inline" TickFrequency="10" />

+ 8 - 0
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -112,6 +112,7 @@ void SDLPal::MainPage::LoadControlContents(bool loadDefault)
 	cbCD->SelectedIndex = (gConfig.eCDType == MUSIC_MP3) ? 0 : 1;
 	cbBGM->SelectedIndex = (gConfig.eMusicType <= MUSIC_OGG) ? gConfig.eMusicType : MUSIC_RIX;
 	cbOPL->SelectedIndex = (int)gConfig.eOPLType;
+	cbAspectRatio->SelectedIndex = gConfig.dwAspectY == 0 ? 0 : [](std::vector<float> &array, float toMatch) {return std::find_if(array.begin(), array.end(), [toMatch](float i)->bool { return fabs(toMatch - i) < FLT_EPSILON; }) - array.begin(); }(std::vector<float>({ 16.0f / 10.0f, 4.0f / 3.0f }), (float)gConfig.dwAspectX / gConfig.dwAspectY);
 
 	if (gConfig.iSampleRate <= 11025)
 		cbSampleRate->SelectedIndex = 0;
@@ -159,6 +160,13 @@ void SDLPal::MainPage::SaveControlContents()
 	gConfig.eMusicType = (MUSICTYPE)cbBGM->SelectedIndex;
 	gConfig.eOPLType = (OPLTYPE)cbOPL->SelectedIndex;
 
+	wchar_t *lasts;
+	wchar_t *selectedAspectRatio = (wchar_t*)static_cast<Platform::String^>(static_cast<ComboBoxItem^>(cbAspectRatio->SelectedItem)->Content)->Data();
+	wchar_t *w=wcstok_s(selectedAspectRatio, L":", &lasts);
+	gConfig.dwAspectX = _wtoi(w);
+	w = wcstok_s(NULL, L":", &lasts);
+	gConfig.dwAspectY = _wtoi(w);
+
 	gConfig.iSampleRate = wcstoul(static_cast<Platform::String^>(static_cast<ComboBoxItem^>(cbSampleRate->SelectedItem)->Content)->Data(), nullptr, 10);
 	gConfig.iOPLSampleRate = wcstoul(static_cast<Platform::String^>(static_cast<ComboBoxItem^>(cbOPLSR->SelectedItem)->Content)->Data(), nullptr, 10);
 	gConfig.wAudioBufferSize = wcstoul(static_cast<Platform::String^>(static_cast<ComboBoxItem^>(cbAudioBuffer->SelectedItem)->Content)->Data(), nullptr, 10);

+ 2 - 0
winrt/pal_config.h

@@ -57,6 +57,8 @@
 
 #define PAL_IS_PATH_SEPARATOR(x) ((x) == '\\' || (x) == '/')
 
+#define strtok_r strtok_s
+
 PAL_C_LINKAGE_BEGIN
 
 LPCSTR