Compare commits
2 Commits
mtsTest
...
AdvancedMenu
| Author | SHA1 | Date | |
|---|---|---|---|
| 5091012cfb | |||
| 87a769c461 |
@@ -59,8 +59,8 @@ public:
|
||||
void SetIR(int player, float x, float y);
|
||||
|
||||
void processSpecialKeys (int button , int player);
|
||||
void setWiimoteSideways (int player);
|
||||
void setWiimoteUpright (int player);
|
||||
void setWiimoteSideways (int player, bool sideways);
|
||||
void setWiimoteUpright (int player, bool upright);
|
||||
void changeWiimoteExtension(int extension, int player);
|
||||
|
||||
void toggleAudioMute();
|
||||
|
||||
+10
-7
@@ -491,29 +491,32 @@ void DolHost::SetAxis(int button, float value, int player)
|
||||
|
||||
void DolHost::processSpecialKeys (int button , int player)
|
||||
{
|
||||
player -= 1;
|
||||
button += 1;
|
||||
|
||||
if (button == OEWiimoteSideways) {
|
||||
_wmSideways[player] = !_wmSideways[player];
|
||||
setWiimoteSideways(player);
|
||||
setWiimoteSideways(player, _wmSideways[player - 1]);
|
||||
} else if (button == OEWiimoteUpright) {
|
||||
_wmUpright[player] = !_wmUpright[player];
|
||||
setWiimoteUpright(player);
|
||||
setWiimoteUpright(player ,_wmUpright[player - 1]);
|
||||
}
|
||||
}
|
||||
void DolHost::setWiimoteSideways (int player)
|
||||
|
||||
void DolHost::setWiimoteSideways (int player, bool sideways)
|
||||
{
|
||||
static_cast<ControllerEmu::NumericSetting<bool>*>(Wiimote::GetWiimoteGroup(player, WiimoteEmu::WiimoteGroup::Options)->numeric_settings[3].get())->SetValue(_wmSideways[player]);
|
||||
player -= 1;
|
||||
static_cast<ControllerEmu::NumericSetting<bool>*>(Wiimote::GetWiimoteGroup(player, WiimoteEmu::WiimoteGroup::Options)->numeric_settings[3].get())->SetValue(sideways);
|
||||
}
|
||||
|
||||
void DolHost::setWiimoteUpright (int player)
|
||||
void DolHost::setWiimoteUpright (int player, bool upright)
|
||||
{
|
||||
static_cast<ControllerEmu::NumericSetting<bool>*>(Wiimote::GetWiimoteGroup(player, WiimoteEmu::WiimoteGroup::Options)->numeric_settings[2].get())->SetValue(_wmUpright[player]);
|
||||
player -= 1;
|
||||
static_cast<ControllerEmu::NumericSetting<bool>*>(Wiimote::GetWiimoteGroup(player, WiimoteEmu::WiimoteGroup::Options)->numeric_settings[2].get())->SetValue(upright);
|
||||
}
|
||||
|
||||
void DolHost::changeWiimoteExtension(int extension, int player)
|
||||
{
|
||||
|
||||
player -= 1;
|
||||
static_cast<ControllerEmu::Attachments*>(Wiimote::GetWiimoteGroup(player, WiimoteEmu::WiimoteGroup::Attachments))->SetSelectedAttachment(extension);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ extern std::unique_ptr<SoundStream> g_sound_stream;
|
||||
NSString *_dolphinCoreModule;
|
||||
OEIntSize _dolphinCoreAspect;
|
||||
OEIntSize _dolphinCoreScreen;
|
||||
|
||||
NSMutableArray <NSMutableDictionary <NSString *, id> *> *_advancedMenus;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
@@ -145,6 +147,9 @@ extern std::unique_ptr<SoundStream> g_sound_stream;
|
||||
|
||||
_frameInterval = dol_host->GetFrameInterval();
|
||||
|
||||
if (_isWii)
|
||||
[self changeAdvancedMenuOption:@"Wiimote" menuID:@"Controller1"];
|
||||
|
||||
}
|
||||
[super startEmulation];
|
||||
|
||||
@@ -407,4 +412,271 @@ extern std::unique_ptr<SoundStream> g_sound_stream;
|
||||
{
|
||||
dol_host->SetCheat([code UTF8String], [type UTF8String], enabled);
|
||||
}
|
||||
|
||||
# pragma mark - Advanced Menu Functions (do not change)
|
||||
- (void)changeAdvancedMenuOption:(NSString *)advancedMenuName menuID:(NSString *)menuID
|
||||
{
|
||||
if (_advancedMenus.count == 0)
|
||||
[self advancedMenu];
|
||||
|
||||
// First check if Menu Option is toggleable and grab its preference key
|
||||
BOOL isMenuToggleable = NO;
|
||||
BOOL isValidMenu = NO;
|
||||
BOOL menuState = NO;
|
||||
NSString *menuPrefKey;
|
||||
NSString *menuIDKey;
|
||||
|
||||
for (NSDictionary *menuDict in _advancedMenus)
|
||||
{
|
||||
if (menuDict[OEGameCoreAdvancedMenuGroupNameKey]){
|
||||
NSDictionary *subMenuDict = [self findAdvancedSubMenu:menuDict menuName:advancedMenuName menuID:menuID];
|
||||
if (subMenuDict){
|
||||
menuState = [subMenuDict[OEGameCoreAdvancedMenuStateKey] boolValue];
|
||||
menuPrefKey = subMenuDict[OEGameCoreAdvancedMenuPrefKeyNameKey];
|
||||
menuIDKey = subMenuDict[OEGameCoreAdvancedMenuGroupIDKey];
|
||||
isMenuToggleable = [subMenuDict[OEGameCoreAdvancedMenuAllowsToggleKey] boolValue];
|
||||
isValidMenu = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ([menuDict[OEGameCoreAdvancedMenuNameKey] isEqualToString:advancedMenuName])
|
||||
{
|
||||
if ([menuDict[OEGameCoreAdvancedMenuGroupIDKey] isEqualToString:menuID])
|
||||
{
|
||||
menuState = [menuDict[OEGameCoreAdvancedMenuStateKey] boolValue];
|
||||
menuPrefKey = menuDict[OEGameCoreAdvancedMenuPrefKeyNameKey];
|
||||
menuIDKey = menuDict[OEGameCoreAdvancedMenuGroupIDKey];
|
||||
isMenuToggleable = [menuDict[OEGameCoreAdvancedMenuAllowsToggleKey] boolValue];
|
||||
isValidMenu = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidMenu)
|
||||
return;
|
||||
|
||||
// Handle option state changes
|
||||
for (NSMutableDictionary *menuDict in _advancedMenus)
|
||||
{
|
||||
if (menuDict[OEGameCoreAdvancedMenuGroupNameKey]){
|
||||
[self processAdvancedSubMenu:menuDict menuName:advancedMenuName menuID:menuID menuState:menuState menuPrefKey:menuPrefKey menuToggle:isMenuToggleable];
|
||||
}
|
||||
}
|
||||
|
||||
//send the menuname and menuID for actions to be taken
|
||||
[self advancedMenuAction:advancedMenuName menuID:menuID];
|
||||
}
|
||||
|
||||
- (void) processAdvancedSubMenu:(NSMutableDictionary *)parentMenuDict menuName:(NSString *)menuName menuID:(NSString *)menuID menuState:(BOOL)menuState menuPrefKey:(NSString *)menuPrefKey menuToggle:(BOOL)menuToggle;
|
||||
{
|
||||
for (NSMutableDictionary *subMenuDict in parentMenuDict[OEGameCoreAdvancedMenuGroupItemsKey])
|
||||
{
|
||||
//This function iterates through the menu items and sets the option and clears others in the same prefs group or toggles the menu item
|
||||
NSString *curMenuID = subMenuDict[OEGameCoreAdvancedMenuGroupIDKey];
|
||||
|
||||
if (subMenuDict[OEGameCoreAdvancedMenuGroupNameKey]){
|
||||
[self processAdvancedSubMenu:subMenuDict menuName:menuName menuID:menuID menuState:menuState menuPrefKey:menuPrefKey menuToggle:menuToggle];
|
||||
}
|
||||
else if ( [curMenuID isEqualToString:menuID] ){
|
||||
NSString *curMenuName = subMenuDict[OEGameCoreAdvancedMenuNameKey];
|
||||
NSString *curMenuKey = subMenuDict[OEGameCoreAdvancedMenuPrefKeyNameKey];
|
||||
|
||||
if (!curMenuName)
|
||||
continue;
|
||||
// Mutually exclusive option state change
|
||||
else if ([curMenuName isEqualToString:menuName] && !menuToggle)
|
||||
subMenuDict[OEGameCoreAdvancedMenuStateKey] = @YES;
|
||||
// Reset mutually exclusive options that are the same prefs group
|
||||
else if (!menuToggle && [curMenuKey isEqualToString:menuPrefKey])
|
||||
subMenuDict[OEGameCoreAdvancedMenuStateKey] = @NO;
|
||||
// Toggleable option state change
|
||||
else if ([curMenuName isEqualToString:menuName] && menuToggle)
|
||||
subMenuDict[OEGameCoreAdvancedMenuStateKey] = @(!menuState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *) findAdvancedSubMenu:(NSDictionary *)parentMenuDict menuName:(NSString *)menuName menuID:(NSString *)menuID
|
||||
{
|
||||
//This function iterates through the menu items and returns the dictionary item if found
|
||||
NSDictionary *testSubMenuDict;
|
||||
|
||||
for (NSDictionary *subMenuDict in parentMenuDict[OEGameCoreAdvancedMenuGroupItemsKey])
|
||||
{
|
||||
if (subMenuDict[OEGameCoreAdvancedMenuGroupNameKey])
|
||||
{
|
||||
testSubMenuDict = [self findAdvancedSubMenu:subMenuDict menuName:menuName menuID:menuID];
|
||||
|
||||
if (testSubMenuDict)
|
||||
{
|
||||
if ([testSubMenuDict[OEGameCoreAdvancedMenuNameKey] isEqualToString:menuName])
|
||||
{
|
||||
if ([testSubMenuDict[OEGameCoreAdvancedMenuGroupIDKey] isEqualToString:menuID])
|
||||
{
|
||||
return testSubMenuDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ([subMenuDict[OEGameCoreAdvancedMenuNameKey] isEqualToString:menuName])
|
||||
{
|
||||
if ([subMenuDict[OEGameCoreAdvancedMenuGroupIDKey] isEqualToString:menuID])
|
||||
{
|
||||
return subMenuDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
# pragma mark - Advanced Menu Creation
|
||||
|
||||
- (NSArray <NSDictionary <NSString *, id> *> *)advancedMenu
|
||||
{
|
||||
//Create your menu array here. 4 levels deep at most
|
||||
if (_advancedMenus.count == 0)
|
||||
{
|
||||
_advancedMenus = [NSMutableArray array];
|
||||
|
||||
NSArray <NSDictionary <NSString *, id> *> *advancedMenuWithDefault =
|
||||
@[ // Level 1
|
||||
// @{ OEGameCoreAdvancedMenuGroupNameKey : @"Controllers",
|
||||
// OEGameCoreAdvancedMenuGroupIDKey : @"Controllers",
|
||||
// OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// // Level 2
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Controller 1",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller1",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 3
|
||||
OEAdvancedMenu_OptionDefault(@"Wiimote", @"Controller1", @"controller1"),
|
||||
OEAdvancedMenu_Option(@"Sideways Wiimote", @"Controller1", @"controller1"),
|
||||
OEAdvancedMenu_SeparatorItem(),
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Wiimote Attachment",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller1",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 4
|
||||
OEAdvancedMenu_OptionIndentedDefault(@"None", @"Controller1", @"attachment1"),
|
||||
OEAdvancedMenu_OptionIndented(@"Nunckuk", @"Controller1", @"attachment1"),
|
||||
OEAdvancedMenu_OptionIndented(@"Classic Controller", @"Controller1", @"attachment1"),
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
// Level 2
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Controller 2",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller2",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 3
|
||||
OEAdvancedMenu_OptionDefault(@"Wiimote", @"Controller2", @"controller2"),
|
||||
OEAdvancedMenu_Option(@"Sideways Wiimote", @"Controller2", @"controller2"),
|
||||
OEAdvancedMenu_SeparatorItem(),
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Wiimote Attachment",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller2",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 4
|
||||
OEAdvancedMenu_OptionIndentedDefault(@"None", @"Controller2", @"attachment2"),
|
||||
OEAdvancedMenu_OptionIndented(@"Nunckuk", @"Controller2", @"attachment2"),
|
||||
OEAdvancedMenu_OptionIndented(@"Classic Controller", @"Controller2", @"attachment2"),
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
// Level 2
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Controller 3",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller3",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 3
|
||||
OEAdvancedMenu_OptionDefault(@"Wiimote", @"Controller3", @"controller3"),
|
||||
OEAdvancedMenu_Option(@"Sideways Wiimote", @"Controller3", @"controller3"),
|
||||
OEAdvancedMenu_SeparatorItem(),
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Wiimote Attachment",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller3",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 4
|
||||
OEAdvancedMenu_OptionIndentedDefault(@"None", @"Controller3", @"attachment3"),
|
||||
OEAdvancedMenu_OptionIndented(@"Nunckuk", @"Controller3", @"attachment3"),
|
||||
OEAdvancedMenu_OptionIndented(@"Classic Controller", @"Controller3", @"attachment3"),
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
// Level 2
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Controller 4",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller4",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 3
|
||||
OEAdvancedMenu_OptionDefault(@"Wiimote", @"Controller4", @"controller4"),
|
||||
OEAdvancedMenu_Option(@"Sideways Wiimote", @"Controller4", @"controller4"),
|
||||
OEAdvancedMenu_SeparatorItem(),
|
||||
@{ OEGameCoreAdvancedMenuGroupNameKey : @"Wiimote Attachment",
|
||||
OEGameCoreAdvancedMenuGroupIDKey : @"Controller4",
|
||||
OEGameCoreAdvancedMenuGroupItemsKey : @[
|
||||
// Level 4
|
||||
OEAdvancedMenu_OptionIndentedDefault(@"None", @"Controller4", @"attachment4"),
|
||||
OEAdvancedMenu_OptionIndented(@"Nunckuk", @"Controller4", @"attachment4"),
|
||||
OEAdvancedMenu_OptionIndented(@"Classic Controller", @"Controller4", @"attachment4"),
|
||||
]
|
||||
},
|
||||
]
|
||||
// },
|
||||
// ]
|
||||
},
|
||||
];
|
||||
|
||||
// Deep mutable copy
|
||||
_advancedMenus = (NSMutableArray *)CFBridgingRelease(CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (CFArrayRef)advancedMenuWithDefault, kCFPropertyListMutableContainers));
|
||||
}
|
||||
return [_advancedMenus copy];
|
||||
}
|
||||
|
||||
# pragma mark - Advanced Menu Actions Processing
|
||||
|
||||
- (void)advancedMenuAction:(NSString *)advancedMenuName menuID:(NSString *)menuID
|
||||
{
|
||||
//Write your code to process Clicked menu items here
|
||||
int player = 0;
|
||||
|
||||
if ([menuID isEqualToString:@"Controller1"]){
|
||||
player = 1;
|
||||
}
|
||||
if ([menuID isEqualToString:@"Controller2"]){
|
||||
player = 2;
|
||||
}
|
||||
if ([menuID isEqualToString:@"Controller3"]){
|
||||
player = 3;
|
||||
}
|
||||
if ([menuID isEqualToString:@"Controller4"]){
|
||||
player = 4;
|
||||
}
|
||||
|
||||
if (player){
|
||||
if ([advancedMenuName isEqualToString:@"Wiimote"])
|
||||
{
|
||||
dol_host->setWiimoteSideways(player, false);
|
||||
return;
|
||||
}
|
||||
if ([advancedMenuName isEqualToString:@"Sideways Wiimote"])
|
||||
{
|
||||
dol_host->setWiimoteSideways(player, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if ([advancedMenuName isEqualToString:@"none"])
|
||||
{
|
||||
dol_host->changeWiimoteExtension(0, player);
|
||||
return;
|
||||
}
|
||||
if ([advancedMenuName isEqualToString:@"Nunchuk"])
|
||||
{
|
||||
dol_host->changeWiimoteExtension(1, player);
|
||||
return;
|
||||
}
|
||||
if ([advancedMenuName isEqualToString:@"Classic Controller"])
|
||||
{
|
||||
dol_host->changeWiimoteExtension(2, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
<dict>
|
||||
<key>OEGameCoreHasGlitches</key>
|
||||
<true/>
|
||||
<key>OEGameCoreSupportsAdvancedMenu</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>OEGameCorePlayerCount</key>
|
||||
|
||||
Reference in New Issue
Block a user