enabled OK button on GuiCombat screen when choosing defenders/attackers. iOS solution only currently. To implement in Android, we need to create a mask/invisible button above the OK button coordinates and add a listener to activate when a user touches the appropriate area. Not ideal, but it works for now.
TODO: translate functionality into core of engine.
This commit is contained in:
@@ -371,6 +371,7 @@ class JGE
|
|||||||
/// and in IOS to communicate with the EAGL layer
|
/// and in IOS to communicate with the EAGL layer
|
||||||
void SendCommand(std::string command);
|
void SendCommand(std::string command);
|
||||||
void SendCommand(std::string command, std::string parameter);
|
void SendCommand(std::string command, std::string parameter);
|
||||||
|
void SendCommand(std::string command, float& x, float& y, float& width, float& height);
|
||||||
|
|
||||||
#if defined (ANDROID)
|
#if defined (ANDROID)
|
||||||
/// Access to JNI Environment
|
/// Access to JNI Environment
|
||||||
|
|||||||
+16
-1
@@ -589,6 +589,8 @@ void JGE::SendCommand(string command)
|
|||||||
{
|
{
|
||||||
#if defined (ANDROID)
|
#if defined (ANDROID)
|
||||||
sendJNICommand(command);
|
sendJNICommand(command);
|
||||||
|
#elif defined (IOS)
|
||||||
|
SendCommand(command, "");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,13 +599,25 @@ void JGE::SendCommand(std::string command, std::string parameter)
|
|||||||
#if defined (IOS)
|
#if defined (IOS)
|
||||||
// get the app delegate and have it handle the command
|
// get the app delegate and have it handle the command
|
||||||
wagicAppDelegate *delegate = [ [UIApplication sharedApplication] delegate];
|
wagicAppDelegate *delegate = [ [UIApplication sharedApplication] delegate];
|
||||||
DebugTrace("Command: "<< command << " with parameter: " << parameter << endl);
|
|
||||||
[delegate handleWEngineCommand:[NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding]
|
[delegate handleWEngineCommand:[NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding]
|
||||||
withParameter: [NSString stringWithCString: parameter.c_str() encoding:NSUTF8StringEncoding]];
|
withParameter: [NSString stringWithCString: parameter.c_str() encoding:NSUTF8StringEncoding]];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this controls commands meant to modify/interact with UI
|
||||||
|
void JGE::SendCommand(std::string command, float& x, float& y, float& width, float& height)
|
||||||
|
{
|
||||||
|
#ifdef ANDROID
|
||||||
|
|
||||||
|
#elif IOS
|
||||||
|
wagicAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
|
||||||
|
[delegate handleWEngineCommand: [NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding] withUIParameters: x yCoordinate: y width: width height: height];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined (ANDROID)
|
#if defined (ANDROID)
|
||||||
/// Access to JNI Environment
|
/// Access to JNI Environment
|
||||||
void JGE::SetJNIEnv(JNIEnv * env, jclass cls)
|
void JGE::SetJNIEnv(JNIEnv * env, jclass cls)
|
||||||
@@ -621,5 +635,6 @@ void JGE::SendCommand(std::string command, std::string parameter)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
std::queue< pair< pair<LocalKeySym, JButton>, bool> > JGE::keyBuffer;
|
std::queue< pair< pair<LocalKeySym, JButton>, bool> > JGE::keyBuffer;
|
||||||
std::multimap<LocalKeySym, JButton> JGE::keyBinds;
|
std::multimap<LocalKeySym, JButton> JGE::keyBinds;
|
||||||
|
|||||||
@@ -6,8 +6,11 @@
|
|||||||
BOOL bannerIsVisible;
|
BOOL bannerIsVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)addOkButtonListener: (CGRect) frame;
|
||||||
|
|
||||||
@property (nonatomic, retain) id eaglView;
|
@property (nonatomic, retain) id eaglView;
|
||||||
@property (nonatomic, retain) UITextField *inputField;
|
@property (nonatomic, retain) UITextField *inputField;
|
||||||
|
@property (nonatomic, retain) UIButton *okButtonView;
|
||||||
@property (nonatomic, assign) BOOL bannerIsVisible;
|
@property (nonatomic, assign) BOOL bannerIsVisible;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
@synthesize bannerIsVisible;
|
@synthesize bannerIsVisible;
|
||||||
@synthesize eaglView;
|
@synthesize eaglView;
|
||||||
|
@synthesize okButtonView;
|
||||||
@synthesize inputField;
|
@synthesize inputField;
|
||||||
|
|
||||||
#pragma mark initialization / deallocation methods
|
#pragma mark initialization / deallocation methods
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
[eaglView setDelegate: nil];
|
[eaglView setDelegate: nil];
|
||||||
[eaglView release], eaglView = nil;
|
[eaglView release], eaglView = nil;
|
||||||
[inputField release], inputField = nil;
|
[inputField release], inputField = nil;
|
||||||
|
[okButtonView release], okButtonView = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +88,32 @@
|
|||||||
// e.g. self.myOutlet = nil;
|
// e.g. self.myOutlet = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - UIView Creation
|
||||||
|
- (void)addOkButtonListener: (CGRect) frame
|
||||||
|
{
|
||||||
|
// create an invisible view to handle the pressing of the OK button.
|
||||||
|
if ( okButtonView == nil )
|
||||||
|
{
|
||||||
|
okButtonView = [[UIButton alloc] initWithFrame: frame];
|
||||||
|
[okButtonView setBackgroundColor: [UIColor clearColor]];
|
||||||
|
[okButtonView setEnabled: YES];
|
||||||
|
[okButtonView addTarget: self.view action:@selector(handleOK:) forControlEvents: UIControlEventTouchUpInside];
|
||||||
|
[self.view addSubview: okButtonView];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self.view bringSubviewToFront: okButtonView];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
- (void)removeOkButtonListener
|
||||||
|
{
|
||||||
|
[[self.view.subviews lastObject] removeFromSuperview];
|
||||||
|
[okButtonView release], okButtonView = nil;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark device orientation handlers
|
|
||||||
|
#pragma mark - device orientation handlers
|
||||||
|
|
||||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||||
// Overriden to allow any orientation.
|
// Overriden to allow any orientation.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
- (void) rotateBackgroundImage:(UIInterfaceOrientation)fromInterfaceOrientation toInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
|
- (void) rotateBackgroundImage:(UIInterfaceOrientation)fromInterfaceOrientation toInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
|
||||||
|
|
||||||
- (void) handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter;
|
- (void) handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter;
|
||||||
|
- (void) handleWEngineCommand:(NSString *) command withUIParameters: (CGFloat) x yCoordinate: (CGFloat) y width: (CGFloat) width height: (CGFloat) height;
|
||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
||||||
@property (nonatomic, retain) EAGLViewController *glViewController;
|
@property (nonatomic, retain) EAGLViewController *glViewController;
|
||||||
|
|||||||
@@ -144,6 +144,16 @@
|
|||||||
[self.glViewController toggleKeyboardWithState: initialState];
|
[self.glViewController toggleKeyboardWithState: initialState];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) handleWEngineCommand:(NSString *) command
|
||||||
|
withUIParameters: (CGFloat) x
|
||||||
|
yCoordinate: (CGFloat) y
|
||||||
|
width: (CGFloat) width
|
||||||
|
height: (CGFloat) height
|
||||||
|
{
|
||||||
|
CGRect uiFrame = CGRectMake(x, y, width, height);
|
||||||
|
if ( [command isEqualToString: @"okbuttoncreated"] )
|
||||||
|
[glViewController addOkButtonListener: uiFrame];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter
|
- (void)handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter
|
||||||
{
|
{
|
||||||
@@ -165,6 +175,10 @@
|
|||||||
{
|
{
|
||||||
[self initializeKeyboard: parameter];
|
[self initializeKeyboard: parameter];
|
||||||
}
|
}
|
||||||
|
else if ([command isEqualToString: @"combatGuiEndDamage"])
|
||||||
|
{
|
||||||
|
[glViewController removeOkButtonListener];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -190,8 +190,7 @@ static NSString *kDownloadFileName = @"core_017_iOS.zip";
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Application Lifecycle
|
||||||
#pragma mark Application Lifecycle
|
|
||||||
|
|
||||||
|
|
||||||
- (void) didReceiveMemoryWarning
|
- (void) didReceiveMemoryWarning
|
||||||
@@ -203,8 +202,7 @@ static NSString *kDownloadFileName = @"core_017_iOS.zip";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark - UIView Delegate
|
||||||
#pragma mark UIView Delegate
|
|
||||||
|
|
||||||
- (void) handleRotation: (UIInterfaceOrientation) interfaceOrientation
|
- (void) handleRotation: (UIInterfaceOrientation) interfaceOrientation
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,10 +7,6 @@
|
|||||||
#include "StyleManager.h"
|
#include "StyleManager.h"
|
||||||
#include "Credits.h"
|
#include "Credits.h"
|
||||||
|
|
||||||
#ifdef IOS
|
|
||||||
#include "JGE.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const string Options::optionNames[] = {
|
const string Options::optionNames[] = {
|
||||||
//Global options
|
//Global options
|
||||||
"Profile",
|
"Profile",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ GuiCombat::GuiCombat(GameObserver* go) :
|
|||||||
if (NULL == ok_tex && go->getResourceManager())
|
if (NULL == ok_tex && go->getResourceManager())
|
||||||
{
|
{
|
||||||
ok_tex = go->getResourceManager()->RetrieveTexture("Ok.png", RETRIEVE_LOCK);
|
ok_tex = go->getResourceManager()->RetrieveTexture("Ok.png", RETRIEVE_LOCK);
|
||||||
|
// send a message out to listeners that we created the GO button and it's location
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +191,7 @@ bool GuiCombat::clickOK()
|
|||||||
case END_FIRST_STRIKE:
|
case END_FIRST_STRIKE:
|
||||||
return false;
|
return false;
|
||||||
case END_DAMAGE:
|
case END_DAMAGE:
|
||||||
|
JGE::GetInstance()->SendCommand("combatGuiEndDamage");
|
||||||
return false; // nothing;
|
return false; // nothing;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -428,6 +430,7 @@ void GuiCombat::Render()
|
|||||||
JQuadPtr ok_quad = WResourceManager::Instance()->RetrieveTempQuad("Ok.png");
|
JQuadPtr ok_quad = WResourceManager::Instance()->RetrieveTempQuad("Ok.png");
|
||||||
ok_quad->SetHotSpot(28, 22);
|
ok_quad->SetHotSpot(28, 22);
|
||||||
ok.Render(ok_quad.get());
|
ok.Render(ok_quad.get());
|
||||||
|
JGE::GetInstance()->SendCommand("okbuttoncreated:", ok.x, ok.y, ok_quad->mWidth, ok_quad->mHeight);
|
||||||
}
|
}
|
||||||
renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
|
renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
|
||||||
if (FIRST_STRIKE == step)
|
if (FIRST_STRIKE == step)
|
||||||
|
|||||||
@@ -498,17 +498,6 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXBuildRule section */
|
/* Begin PBXBuildRule section */
|
||||||
12059E5F14980B7300DAC43B /* PBXBuildRule */ = {
|
|
||||||
isa = PBXBuildRule;
|
|
||||||
compilerSpec = com.apple.compilers.proxy.script;
|
|
||||||
filePatterns = modrules.xml;
|
|
||||||
fileType = pattern.proxy;
|
|
||||||
isEditable = 1;
|
|
||||||
outputFiles = (
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
script = "cp -rp iOS/Res bin/Res";
|
|
||||||
};
|
|
||||||
129654D7148AA2690031100B /* PBXBuildRule */ = {
|
129654D7148AA2690031100B /* PBXBuildRule */ = {
|
||||||
isa = PBXBuildRule;
|
isa = PBXBuildRule;
|
||||||
compilerSpec = com.apple.compilers.proxy.script;
|
compilerSpec = com.apple.compilers.proxy.script;
|
||||||
@@ -1879,7 +1868,6 @@
|
|||||||
12059E4914980B7300DAC43B /* Frameworks */,
|
12059E4914980B7300DAC43B /* Frameworks */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
12059E5F14980B7300DAC43B /* PBXBuildRule */,
|
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
@@ -2437,6 +2425,7 @@
|
|||||||
DEBUG,
|
DEBUG,
|
||||||
DARWIN_NO_CARBON,
|
DARWIN_NO_CARBON,
|
||||||
FT2_BUILD_LIBRARY,
|
FT2_BUILD_LIBRARY,
|
||||||
|
FORCE_GLES,
|
||||||
);
|
);
|
||||||
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
|
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
|
||||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||||
@@ -2482,6 +2471,7 @@
|
|||||||
FT2_BUILD_LIBRARY,
|
FT2_BUILD_LIBRARY,
|
||||||
IOS,
|
IOS,
|
||||||
TESTSUITE,
|
TESTSUITE,
|
||||||
|
FORCE_GLES,
|
||||||
);
|
);
|
||||||
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
|
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
|
||||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||||
|
|||||||
Reference in New Issue
Block a user