diff --git a/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj index 79bcff6..8c4a6f4 100644 --- a/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj +++ b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj @@ -870,7 +870,7 @@ 4C8CE8F915B0A0F400078175 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0430; + LastUpgradeCheck = 0510; }; buildConfigurationList = 4C8CE8FC15B0A0F400078175 /* Build configuration list for PBXProject "Salmon Engine" */; compatibilityVersion = "Xcode 3.2"; @@ -946,8 +946,13 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -958,10 +963,14 @@ ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; @@ -970,13 +979,21 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; diff --git a/include/GUIManager/GUIManager.h b/include/GUIManager/GUIManager.h index 97634fa..0e2c5a9 100644 --- a/include/GUIManager/GUIManager.h +++ b/include/GUIManager/GUIManager.h @@ -22,10 +22,11 @@ extern const std::string CONST_TAPDOWN_SIGNAL_NAME; typedef boost::variant TSignalParam; -struct TWidgetDataStruct +struct TWidgetStruct { std::string Name; std::string GroupName; + int Order; bool IsMouseDown; @@ -33,9 +34,10 @@ struct TWidgetDataStruct std::map>> SignalMap; - TWidgetDataStruct(const std::string& name, const std::string& groupName, std::shared_ptr widget) + TWidgetStruct(const std::string& name, const std::string& groupName, std::shared_ptr widget, int order = 0) : Name(name) , GroupName(groupName) + , Order(order) , IsMouseDown(false) , Widget(widget) { @@ -45,63 +47,30 @@ struct TWidgetDataStruct SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); } - TWidgetDataStruct(const TWidgetDataStruct& widgetStruct) + TWidgetStruct(const TWidgetStruct& widgetStruct) { Name = widgetStruct.Name; Widget = widgetStruct.Widget; GroupName = widgetStruct.GroupName; IsMouseDown = widgetStruct.IsMouseDown; + Order = widgetStruct.Order; SignalMap = widgetStruct.SignalMap; } - TWidgetDataStruct& operator=(const TWidgetDataStruct& widgetStruct) + TWidgetStruct& operator=(const TWidgetStruct& widgetStruct) { //Self-assignment is ok Name = widgetStruct.Name; Widget = widgetStruct.Widget; GroupName = widgetStruct.GroupName; IsMouseDown = widgetStruct.IsMouseDown; + Order = widgetStruct.Order; SignalMap = widgetStruct.SignalMap; return *this; } - ~TWidgetDataStruct() - { - } -}; - - -struct TWidgetStruct -{ - - boost::shared_ptr WidgetData; - - int Order; - - TWidgetStruct(const std::string& name, const std::string& groupName, std::shared_ptr widget, int order = 0) - : WidgetData(new TWidgetDataStruct(name, groupName, widget)) - , Order(order) - { - } - - TWidgetStruct(const TWidgetStruct& widgetStruct) - { - WidgetData = widgetStruct.WidgetData; - Order = widgetStruct.Order; - } - - TWidgetStruct& operator=(const TWidgetStruct& widgetStruct) - { - if (&widgetStruct != this) - { - WidgetData = widgetStruct.WidgetData; - Order = widgetStruct.Order; - } - return *this; - } - ~TWidgetStruct() { } @@ -189,6 +158,8 @@ public: void DeleteWidgetOnUpdate(const std::string& name); void DeleteWidgetGroupOnUpdate(const std::string& groupName); + void DeleteWidgetLaterOnUpdate(const std::string& name); + void DeleteWidgetGroupLaterOnUpdate(const std::string& groupName); void Update(cardinal dt); void Draw(); diff --git a/include/Utils/IosApi/IosApi.h b/include/Utils/IosApi/IosApi.h index c4b25bc..ed8a190 100644 --- a/include/Utils/IosApi/IosApi.h +++ b/include/Utils/IosApi/IosApi.h @@ -27,5 +27,6 @@ void HideKeyboard(); void ClearKeyboardText(); bool IsIpad(); +bool IsIphone5(); } //namespace SE diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp index 4f32d99..a3d5b34 100644 --- a/src/GUIManager/GUIManager.cpp +++ b/src/GUIManager/GUIManager.cpp @@ -48,7 +48,7 @@ void TGUIManager::AddWidget(std::shared_ptr widgetAnc { for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); i++) { - if (i->WidgetData->Name == name) + if (i->Name == name) { return; } @@ -61,7 +61,7 @@ void TGUIManager::DeleteWidget(std::string name) { for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); i++) { - if (i->WidgetData->Name == name) + if (i->Name == name) { WidgetArr.erase(i); return; @@ -75,7 +75,7 @@ void TGUIManager::DeleteWidgetGroup(std::string groupName) for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end();) { widgetErased = false; - if (i->WidgetData->GroupName == groupName) + if (i->GroupName == groupName) { i = WidgetArr.erase(i); widgetErased = true; @@ -90,14 +90,31 @@ void TGUIManager::DeleteWidgetGroup(std::string groupName) void TGUIManager::DeleteWidgetOnUpdate(const std::string& name) { - PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidget, this, name)); + //PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidget, this, name)); + PerformInMainThreadAsync(boost::bind(&TGUIManager::DeleteWidget, this, name)); + } void TGUIManager::DeleteWidgetGroupOnUpdate(const std::string& groupName) { - PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName)); + //PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName)); + PerformInMainThreadAsync(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName)); + } +void TGUIManager::DeleteWidgetLaterOnUpdate(const std::string& name) +{ + PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidget, this, name)); +} + +void TGUIManager::DeleteWidgetGroupLaterOnUpdate(const std::string& groupName) +{ + PerformInMainThreadAsyncLater(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName)); +} + + + + void TGUIManager::AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask) { WidgetTrasfromTaskList.push_back(widgetTransformTask); @@ -113,12 +130,12 @@ void TGUIManager::Update(cardinal dt) { //i->Widget->Update(dt); - if (i->WidgetData->IsMouseDown) + if (i->IsMouseDown) { - signalMap.push_back((i->WidgetData->SignalMap[CONST_HOLD_SIGNAL_NAME])); + signalMap.push_back((i->SignalMap[CONST_HOLD_SIGNAL_NAME])); } - i->WidgetData->Widget->Update(dt); + i->Widget->Update(dt); } @@ -165,7 +182,7 @@ void TGUIManager::Update(cardinal dt) for (TWidgetArr::iterator j = WidgetArr.begin(); j != WidgetArr.end(); ++j) { - if (j->WidgetData->GroupName == i->GroupName) + if (j->GroupName == i->GroupName) { MoveWidgetByIterator(j, moveDistance); } @@ -196,7 +213,7 @@ void TGUIManager::Draw() TRenderPairList::iterator j; - for (j = i->WidgetData->Widget->TriangleListVector.begin(); j != i->WidgetData->Widget->TriangleListVector.end(); ++j) + for (j = i->Widget->TriangleListVector.begin(); j != i->Widget->TriangleListVector.end(); ++j) { TRenderParamsSetter paramSetter(j->first); @@ -215,7 +232,7 @@ TWidgetArr::iterator TGUIManager::FindWidgetInArr(const std::string& widgetName) for (i = WidgetArr.begin(); i != WidgetArr.end(); ++i) { - if (i->WidgetData->Name == widgetName) + if (i->Name == widgetName) { break; } @@ -231,13 +248,13 @@ TWidgetArr::iterator TGUIManager::FindWidgetInArr(const std::string& widgetName) void TGUIManager::MoveWidgetByIterator(TWidgetArr::iterator widget, vec2 shift) { - widget->WidgetData->Widget->LeftBottomPos += shift; + widget->Widget->LeftBottomPos += shift; std::vector::iterator i; TRenderPairList::iterator itr; - for (itr = widget->WidgetData->Widget->TriangleListVector.begin(); itr != widget->WidgetData->Widget->TriangleListVector.end(); ++itr) + for (itr = widget->Widget->TriangleListVector.begin(); itr != widget->Widget->TriangleListVector.end(); ++itr) { std::vector& vertexCoordVec = itr->second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]; @@ -261,7 +278,7 @@ void TGUIManager::MoveWidgetGroup(const std::string& widgetGroupName, const std: { for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); ++i) { - if (i->WidgetData->GroupName == widgetGroupName && i->WidgetData->Name != exceptWidget) + if (i->GroupName == widgetGroupName && i->Name != exceptWidget) { MoveWidgetByIterator(i, shift); } @@ -285,14 +302,14 @@ void TGUIManager::OnMouseDown(vec2 pos, int touchNumber) for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { - if (i->WidgetData->Widget->CheckClick(pos)) + if (i->Widget->CheckClick(pos)) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); + bool isTransparentForInput = i->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnTapDown(pos); - i->WidgetData->IsMouseDown = true; + i->Widget->OnTapDown(pos); + i->IsMouseDown = true; - signalMap.push_back((i->WidgetData->SignalMap[CONST_TAPDOWN_SIGNAL_NAME])); + signalMap.push_back((i->SignalMap[CONST_TAPDOWN_SIGNAL_NAME])); if (! isTransparentForInput) { @@ -323,13 +340,13 @@ void TGUIManager::OnMouseUp(vec2 pos, int touchNumber) for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { - if (i->WidgetData->Widget->CheckClick(pos)) + if (i->Widget->CheckClick(pos)) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnTapUp(pos); - i->WidgetData->IsMouseDown = false; + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + i->Widget->OnTapUp(pos); + i->IsMouseDown = false; - signalMap.push_back((i->WidgetData->SignalMap[CONST_CLICK_SIGNAL_NAME])); + signalMap.push_back((i->SignalMap[CONST_CLICK_SIGNAL_NAME])); if (! isTransparentForInput) { @@ -361,11 +378,11 @@ void TGUIManager::OnMouseUp(vec2 pos, int touchNumber) for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { - if (i->WidgetData->Widget->CheckClick(pos)) + if (i->Widget->CheckClick(pos)) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnTapUpAfterMove(pos); - i->WidgetData->IsMouseDown = false; + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + i->Widget->OnTapUpAfterMove(pos); + i->IsMouseDown = false; //signalMap.push_back((i->SignalMap[CONST_CLICK_SIGNAL_NAME])); //Do not call signals here @@ -376,11 +393,11 @@ void TGUIManager::OnMouseUp(vec2 pos, int touchNumber) } } - if (i->WidgetData->Widget->CheckClick(LastTapPos[touchNumber]) && !i->WidgetData->Widget->CheckClick(pos)) + if (i->Widget->CheckClick(LastTapPos[touchNumber]) && !i->Widget->CheckClick(pos)) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnTapUpAfterMoveOut(pos); - i->WidgetData->IsMouseDown = false; + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + i->Widget->OnTapUpAfterMoveOut(pos); + i->IsMouseDown = false; //signalMap.push_back((i->SignalMap[CONST_CLICK_SIGNAL_NAME])); //Do not call signals here @@ -421,13 +438,13 @@ void TGUIManager::OnMove(vec2 shift, int touchNumber) for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { - if (!moveIsProcessed && i->WidgetData->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber])) + if (!moveIsProcessed && i->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber])) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); + bool isTransparentForInput = i->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnMove(shift); + i->Widget->OnMove(shift); - signalMap.push_back((i->WidgetData->SignalMap[CONST_DRAG_SIGNAL_NAME])); + signalMap.push_back((i->SignalMap[CONST_DRAG_SIGNAL_NAME])); if (! isTransparentForInput) { @@ -445,12 +462,12 @@ void TGUIManager::OnMove(vec2 shift, int touchNumber) for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { - if (!moveOutIsProcessed && i->WidgetData->Widget->CheckClick(LastTapPos[touchNumber]) && !i->WidgetData->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber])) + if (!moveOutIsProcessed && i->Widget->CheckClick(LastTapPos[touchNumber]) && !i->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber])) { - bool isTransparentForInput = i->WidgetData->Widget->IsTransparentForInput(); + bool isTransparentForInput = i->Widget->IsTransparentForInput(); - i->WidgetData->Widget->OnMoveOut(); - i->WidgetData->IsMouseDown = false; + i->Widget->OnMoveOut(); + i->IsMouseDown = false; if (! isTransparentForInput) { moveOutIsProcessed = true; @@ -512,7 +529,7 @@ void TGUIManager::PrintWidgetList() for (i = WidgetArr.begin(); i != WidgetArr.end(); ++i) { - std::string widgetRow = i->WidgetData->Name + " (" + tostr(i->WidgetData->Widget->LeftBottomPos.v[0]) + ", " + tostr(i->WidgetData->Widget->LeftBottomPos.v[1]) + ")"; + std::string widgetRow = i->Name + " (" + tostr(i->Widget->LeftBottomPos.v[0]) + ", " + tostr(i->Widget->LeftBottomPos.v[1]) + ")"; Console->PrintImmediate(widgetRow); } } @@ -523,7 +540,7 @@ std::shared_ptr> TGUIManager::GetOnClickSigna TWidgetArr::iterator i = FindWidgetInArr(widgetName); - return i->WidgetData->SignalMap[CONST_CLICK_SIGNAL_NAME]; + return i->SignalMap[CONST_CLICK_SIGNAL_NAME]; } @@ -532,7 +549,7 @@ std::shared_ptr> TGUIManager::GetOnHoldSignal TWidgetArr::iterator i = FindWidgetInArr(widgetName); - return i->WidgetData->SignalMap[CONST_HOLD_SIGNAL_NAME]; + return i->SignalMap[CONST_HOLD_SIGNAL_NAME]; } @@ -541,7 +558,7 @@ std::shared_ptr> TGUIManager::GetOnTapDownSig TWidgetArr::iterator i = FindWidgetInArr(widgetName); - return i->WidgetData->SignalMap[CONST_TAPDOWN_SIGNAL_NAME]; + return i->SignalMap[CONST_TAPDOWN_SIGNAL_NAME]; } @@ -550,12 +567,12 @@ std::shared_ptr> TGUIManager::GetSignal(const TWidgetArr::iterator i = FindWidgetInArr(widgetName); - if (i->WidgetData->SignalMap.count(signalName) == 0) + if (i->SignalMap.count(signalName) == 0) { throw ErrorToLog("Illegal signal: "+signalName); } - return i->WidgetData->SignalMap[signalName]; + return i->SignalMap[signalName]; } void TGUIManager::SQ_MoveWidget(const SQChar *widgetName, float x, float y) diff --git a/src/Utils/IosApi/IosApi.mm b/src/Utils/IosApi/IosApi.mm index fc32cb0..03a7e7e 100644 --- a/src/Utils/IosApi/IosApi.mm +++ b/src/Utils/IosApi/IosApi.mm @@ -104,6 +104,17 @@ bool IsIpad() } return NO; } + +bool IsIphone5() +{ + if ([[UIScreen mainScreen] bounds].size.height == 568) + { + return YES; /* Device is iPhone5 */ + } + return NO; +} + + } //namespace SE