Commit 3e675c73 authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

Added resizable Virtual Gamepad option.

parent f9f7a2d7
......@@ -72,6 +72,7 @@ public:
bool mVPad = true;
#else
bool mVPad = false;
int mVPadSize = 100;
#endif
#endif
......
include_directories(${SDL_INCLUDE_DIR})
FILE(GLOB_RECURSE srcs *.cpp *.h)
add_subdirectory(menu)
add_subdirectory(mode)
add_subdirectory(VGamepads)
add_library(engine_core ${srcs})
set(SRCS ActionFormat.cpp
CBehaviorEngine.cpp
CCamera.cpp
CHUD.cpp
CIntro.cpp
CMap.cpp
CMessages.cpp
CObjectCollision.cpp
CPassive.cpp
CPhysicsSettings.cpp
CPlane.cpp
CPlanes.cpp
CResourceLoader.cpp
CSettings.cpp
CSpriteObject.cpp
GameEngine.cpp
inventory.cpp
textmode.cpp
ActionFormat.h
CBehaviorEngine.h
CCamera.h
CEvent.h
Cheat.h
CHUD.h
CIntro.h
CMap.h
CMessages.h
CPassive.h
CPhysicsSettings.h
CPlane.h
CPlanes.h
CResourceLoader.h
CSettings.h
CSpriteObject.h
direction.h
GameEngine.h
inventory.h
objenums.h
options.h
Playerdefines.h
spritedefines.h
textmode.h
videoAspect.h)
target_link_libraries(engine_core sdl_extensions_audio sdl_extensions_sys)
add_library(engine_core ${SRCS})
target_link_libraries(engine_core engine_core_menu)
target_link_libraries(engine_core engine_core_mode)
target_link_libraries(engine_core engine_core_vgamepad)
target_link_libraries(engine_core sdl_extensions_audio sdl_extensions_sys)
......
......@@ -8,6 +8,7 @@
#include <base/GsLogging.h>
#include <base/utils/FindFile.h>
#include <base/utils/ConfigHandler.h>
#include <base/CInput.h>
#include "CSettings.h"
#include <base/GsTimer.h>
#include "sdl/audio/Audio.h"
......@@ -16,6 +17,7 @@
#include "CBehaviorEngine.h"
#include "fileio/CConfiguration.h"
#include "fileio/KeenFiles.h"
#include "engine/core/VGamepads/vgamepadsimple.h"
......@@ -72,6 +74,7 @@ bool CSettings::saveDrvCfg()
Configuration.SetKeyword("Video", "OpenGL", VidConf.mOpengl);
#ifdef VIRTUALPAD
Configuration.SetKeyword("Video", "VirtPad", VidConf.mVPad);
Configuration.WriteInt("Video", "VirtPadSize", VidConf.mVPadSize);
#endif
Configuration.SetKeyword("Video", "ShowCursor", VidConf.mShowCursor);
Configuration.SetKeyword("Video", "TiltedScreen", VidConf.mTiltedScreen);
......@@ -195,6 +198,7 @@ bool CSettings::loadDrvCfg()
Configuration.ReadString("Video", "OGLfilter", VidConf.mRenderScQuality, "nearest");
#ifdef VIRTUALPAD
Configuration.ReadKeyword("Video", "VirtPad", &VidConf.mVPad, VidConf.mVPad);
Configuration.ReadInteger("Video", "VirtPadSize", &VidConf.mVPadSize, VidConf.mVPadSize);
#endif
Configuration.ReadKeyword("Video", "ShowCursor", &VidConf.mShowCursor, true);
Configuration.ReadKeyword("Video", "TiltedScreen", &VidConf.mTiltedScreen, false);
......@@ -228,6 +232,8 @@ bool CSettings::loadDrvCfg()
gSound.setMusicVolume(Uint8(music_vol), false);
gSound.setSoundVolume(Uint8(sound_vol), false);
}
return true;
}
......
include_directories(${SDL_INCLUDE_DIR})
set(SRCS
button1.h
button2.h
button3.h
button4.h
buttonBg.h
buttonClose.h
buttonConfirm.h
buttonStart.h
dpad.h
vgamepadsimple.cpp
vgamepadsimple.h
)
add_library(engine_core_vgamepad ${SRCS})
......@@ -126,10 +126,14 @@ bool VirtualKeenControl::ponder()
const float left = 0.025f;
const float right = 0.975f;
const auto iSize = gVideoDriver.getVidConfig().mVPadSize;
float sizeFactor = float(iSize)/200.0f;
if(!mPadBackground.invisible)
{
const GsRect<float> dpadRect(0.0f, 0.75f,
1.0f, 0.25f);
const GsRect<float> dpadRect(0.0f, bottom-sizeFactor*0.25f,
1.0f, 0.25f*sizeFactor);
mPadBackground.setRect(dpadRect);
......@@ -138,9 +142,9 @@ bool VirtualKeenControl::ponder()
if(!mDPad.invisible)
{
const float dpadSize = 0.2f;
const float dpadSize = 0.2f*sizeFactor;
const GsRect<float> dpadRect(left, bottom-dpadSize,
const GsRect<float> dpadRect(left, bottom-dpadSize*1.05f,
dpadSize, dpadSize);
mDPad.setRect(dpadRect);
......@@ -150,7 +154,7 @@ bool VirtualKeenControl::ponder()
if(!mConfirmButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> confirmRect(right-2.0f*buttonSize,
bottom-2.0f*buttonSize,
......@@ -163,10 +167,10 @@ bool VirtualKeenControl::ponder()
if(!mStatusButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> statusRect(right-4.0f*buttonSize,
bottom-2.0f*buttonSize,
const GsRect<float> statusRect(right-3.4f*buttonSize,
bottom-2.2f*buttonSize,
buttonSize, buttonSize);
mStatusButton.setRect(statusRect);
......@@ -176,10 +180,10 @@ bool VirtualKeenControl::ponder()
if(!mStartButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> startRect(right-3.0f*buttonSize,
bottom-2.0f*buttonSize,
const GsRect<float> startRect(right-3.4f*buttonSize,
bottom-1.0f*buttonSize,
buttonSize, buttonSize);
mStartButton.setRect(startRect);
......@@ -189,9 +193,9 @@ bool VirtualKeenControl::ponder()
if(!mJumpButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> jumpRect(right-2.0f*buttonSize,
const GsRect<float> jumpRect(right-2.2f*buttonSize,
bottom-1.0f*buttonSize,
buttonSize, buttonSize);
......@@ -202,7 +206,7 @@ bool VirtualKeenControl::ponder()
if(!mPogoButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> pogoRect(right-1.0f*buttonSize,
bottom-1.0f*buttonSize,
......@@ -215,10 +219,10 @@ bool VirtualKeenControl::ponder()
if(!mShootButton.invisible)
{
const float buttonSize = 0.1f;
const float buttonSize = 0.1f*sizeFactor;
const GsRect<float> shootRect(right-2.0f*buttonSize,
bottom-2.0f*buttonSize,
const GsRect<float> shootRect(right-2.2f*buttonSize,
bottom-2.2f*buttonSize,
buttonSize, buttonSize);
mShootButton.setRect(shootRect);
......
include_directories(${SDL_INCLUDE_DIR})
add_subdirectory(widgets)
set(SRCS
AudioSettings.cpp
AudioSettings.h
cheatsmenu.cpp
cheatsmenu.h
ControlSettings.cpp
ControlSettings.h
CProfilesMenu.cpp
CProfilesMenu.h
CVideoSettings.cpp
CVideoSettings.h
DisplaySettings.cpp
DisplaySettings.h
GameMenu.cpp
GameMenu.h
LoadMenu.cpp
LoadMenu.h
MainMenu.cpp
MainMenu.h
Options.cpp
Options.h
SaveMenu.cpp
SaveMenu.h
selectionmenu.cpp
SelectionMenu.h
SettingsMenu.cpp
SettingsMenu.h
VpadSettings.cpp
VpadSettings.h
)
add_library(engine_core_menu ${SRCS})
Target_link_libraries(engine_core_menu engine_core_menu_widgets)
# TODO: Not sure why Windows requires this yet.
#if(WIN32)
# Target_link_libraries(engine_core SDL2)
#endif(WIN32)
Target_link_libraries(engine_core_menu GsKit)
......@@ -15,6 +15,7 @@
#include "CVideoSettings.h"
#include "DisplaySettings.h"
#include "VpadSettings.h"
//#include "CameraSettings.h"
#include "AudioSettings.h"
#include "Options.h"
......@@ -52,29 +53,43 @@ GameMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.40f),
#if defined (SINGLEPLAYER)
mpMenuDialog->addControl( new GameButton( "Controls",
new OpenMenuEvent( new CControlsettings(1,
style) ),
style ) );
mpMenuDialog->addControl( new GameButton( "Controls",
new OpenMenuEvent( new CControlsettings(1,
style) ),
style ) );
#else
mpMenuDialog->addControl(new GameButton( "Controls",
new OpenMenuEvent( new CPlayersSelection<OpenControlMenuEvent>(false,
style) ),
style ) );
mpMenuDialog->addControl(new GameButton( "Controls",
new OpenMenuEvent( new CPlayersSelection<OpenControlMenuEvent>(false,
style) ),
style ) );
#endif
/*
/*
#if !defined(EMBEDDED)
mpMenuDialog->addControl( new GameButton( "Camera",
new OpenMenuEvent( new CCameraSettings(style) ),
style ) );
#endif
*/
mpMenuDialog->addControl(new GameButton( "Cheats",
new OpenMenuEvent( new CheatsMenu(style) ),
}
#ifdef VIRTUALPAD
mpMenuDialog->addControl(new GameButton( "Virtual Gamepad",
new OpenMenuEvent( new VPadSettingsMenu(style) ),
style ) );
#endif
if(style != GsControl::Style::NONE)
{
mpMenuDialog->addControl(new GameButton( "Cheats",
new OpenMenuEvent( new CheatsMenu(style) ),
style ) );
}
setMenuLabel("CONFIGMENULABEL");
}
/*
* CAudioSettings.cpp
*
* Created on: 28.11.2009
* Author: gerstrong
*/
#include "VpadSettings.h"
#include <base/utils/StringUtils.h>
#include <base/CInput.h>
#include <base/video/CVideoDriver.h>
#include "engine/core/CBehaviorEngine.h"
#include "engine/core/CSettings.h"
#include "engine/core/VGamepads/vgamepadsimple.h"
VPadSettingsMenu::VPadSettingsMenu(const GsControl::Style &style) :
GameMenu(GsRect<float>(0.075f, 0.24f, 0.85f, 0.4f), style )
{
if( gVideoDriver.VGamePadEnabled() )
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
const auto iSizeFac = gVideoDriver.getVidConfig().mVPadSize;
mpSize = new NumberControl( "Size \%", 100, 400, 10, iSizeFac,
false, style );
mpMenuDialog->addControl( mpSize );
}
setMenuLabel("KEYBMENULABEL");
}
void VPadSettingsMenu::refresh()
{
}
void VPadSettingsMenu::ponder(const float /*deltaT*/)
{
GameMenu::ponder(0);
const auto iSize = mpSize->getSelection();
gVideoDriver.getVidConfig().mVPadSize = iSize;
}
void VPadSettingsMenu::release()
{
gSettings.saveDrvCfg();
}
/*
* CAudioSettings.h
*
* Created on: 03.03.2009
* Author: gerstrong
*/
#ifndef CVGAMEPADSETTINGS_H
#define CVGAMEPADSETTINGS_H
#include "engine/core/menu/GameMenu.h"
#include "widgets/NumberControl.h"
#include <SDL.h>
#include <string>
class VPadSettingsMenu : public GameMenu
{
public:
VPadSettingsMenu(const GsControl::Style &style);
void init();
void ponder(const float) override;
void release() override;
void refresh() override;
private:
NumberControl *mpSize;
std::list<std::string> mButtonSizes = { "large", "medium", "small" };
};
#endif /* CVGAMEPADSETTINGS_H */
include_directories(${SDL_INCLUDE_DIR})
set(SRCS
BorderedButton.cpp
BorderedButton.h
Button.cpp
Button.h
ComboSelection.cpp
ComboSelection.h
InputText.cpp
InputText.h
NumberControl.cpp
NumberControl.h
Switch.cpp
Switch.h
)
add_library(engine_core_menu_widgets ${SRCS})
# TODO: Not sure why Windows requires this yet.
#if(WIN32)
# Target_link_libraries(engine_core SDL2)
#endif(WIN32)
Target_link_libraries(engine_core_menu_widgets GsKit)
#ifndef __COMBOSELECTION_H__
#define __COMBOSELECTION_H__
#ifndef COMBOSELECTION_H
#define COMBOSELECTION_H
#include <widgets/GsComboSelection.h>
......
include_directories(${SDL_INCLUDE_DIR})
set(SRCS
CGameMode.h
CGamePlayMode.cpp
CGamePlayMode.h
CPlayGame.cpp
CPlayGame.h)
add_library(engine_core_mode ${SRCS})
# TODO: Not sure why Windows requires this yet.
#if(WIN32)
# Target_link_libraries(engine_core SDL2)
#endif(WIN32)
Target_link_libraries(engine_core_mode GsKit)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment