Retabulate (use only tabs)
This commit is contained in:
parent
f322a3ee52
commit
2cd190d822
|
@ -38,7 +38,7 @@ using namespace Shared::Util;
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Mouse3d
|
// class Mouse3d
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
const float Mouse3d::fadeSpeed= 1.f/50.f;
|
const float Mouse3d::fadeSpeed= 1.f/50.f;
|
||||||
|
@ -65,7 +65,7 @@ void Mouse3d::update(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================
|
// ===============================
|
||||||
// class SelectionQuad
|
// class SelectionQuad
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|
||||||
SelectionQuad::SelectionQuad(){
|
SelectionQuad::SelectionQuad(){
|
||||||
|
@ -89,7 +89,7 @@ void SelectionQuad::disable(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Gui
|
// class Gui
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
//constructor
|
//constructor
|
||||||
|
@ -97,11 +97,11 @@ Gui::Gui(){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||||
|
|
||||||
lastGroupRecall = -1;
|
lastGroupRecall = -1;
|
||||||
commonCommands=0;
|
commonCommands=0;
|
||||||
posObjWorld= Vec2i(54, 14);
|
posObjWorld= Vec2i(54, 14);
|
||||||
validPosObjWorld= false;
|
validPosObjWorld= false;
|
||||||
activeCommandType= NULL;
|
activeCommandType= NULL;
|
||||||
activeCommandClass= ccStop;
|
activeCommandClass= ccStop;
|
||||||
selectingBuilding= false;
|
selectingBuilding= false;
|
||||||
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
||||||
selectingPos= false;
|
selectingPos= false;
|
||||||
|
@ -150,8 +150,8 @@ void Gui::end(){
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
|
||||||
const UnitType *Gui::getBuilding() const{
|
const UnitType *Gui::getBuilding() const{
|
||||||
assert(selectingBuilding);
|
assert(selectingBuilding);
|
||||||
return choosenBuildingType;
|
return choosenBuildingType;
|
||||||
}
|
}
|
||||||
const Object *Gui::getSelectedResourceObject() const{
|
const Object *Gui::getSelectedResourceObject() const{
|
||||||
if(selectedResourceObjectPos.x==-1){
|
if(selectedResourceObjectPos.x==-1){
|
||||||
|
@ -197,17 +197,17 @@ bool Gui::isPlacingBuilding() const{
|
||||||
// ==================== set ====================
|
// ==================== set ====================
|
||||||
|
|
||||||
void Gui::invalidatePosObjWorld(){
|
void Gui::invalidatePosObjWorld(){
|
||||||
validPosObjWorld= false;
|
validPosObjWorld= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== reset state ====================
|
// ==================== reset state ====================
|
||||||
|
|
||||||
void Gui::resetState(){
|
void Gui::resetState(){
|
||||||
selectingBuilding= false;
|
selectingBuilding= false;
|
||||||
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
||||||
selectingPos= false;
|
selectingPos= false;
|
||||||
selectingMeetingPoint= false;
|
selectingMeetingPoint= false;
|
||||||
activePos= invalidPos;
|
activePos= invalidPos;
|
||||||
activeCommandClass= ccStop;
|
activeCommandClass= ccStop;
|
||||||
activeCommandType= NULL;
|
activeCommandType= NULL;
|
||||||
}
|
}
|
||||||
|
@ -216,9 +216,9 @@ void Gui::resetState(){
|
||||||
|
|
||||||
void Gui::update(){
|
void Gui::update(){
|
||||||
|
|
||||||
if(selectionQuad.isEnabled() && selectionQuad.getPosUp().dist(selectionQuad.getPosDown())>minQuadSize){
|
if(selectionQuad.isEnabled() && selectionQuad.getPosUp().dist(selectionQuad.getPosDown())>minQuadSize){
|
||||||
computeSelected(false,false);
|
computeSelected(false,false);
|
||||||
}
|
}
|
||||||
mouse3d.update();
|
mouse3d.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,12 +425,12 @@ void Gui::hotKey(SDL_KeyboardEvent key) {
|
||||||
}
|
}
|
||||||
//else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){
|
//else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){
|
||||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyRotateUnitDuringPlacement"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("HotKeyRotateUnitDuringPlacement"),key) == true) {
|
||||||
// Here the user triggers a unit rotation while placing a unit
|
// Here the user triggers a unit rotation while placing a unit
|
||||||
if(isPlacingBuilding()) {
|
if(isPlacingBuilding()) {
|
||||||
if(getBuilding()->getRotationAllowed()){
|
if(getBuilding()->getRotationAllowed()){
|
||||||
++selectedBuildingFacing;
|
++selectedBuildingFacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else if(key == configKeys.getCharKey("HotKeySelectDamagedUnit")) {
|
//else if(key == configKeys.getCharKey("HotKeySelectDamagedUnit")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("HotKeySelectDamagedUnit"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("HotKeySelectDamagedUnit"),key) == true) {
|
||||||
|
@ -449,18 +449,18 @@ void Gui::hotKey(SDL_KeyboardEvent key) {
|
||||||
clickCommonCommand(ccStop);
|
clickCommonCommand(ccStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<10; i++) {
|
for (int i=0; i<10; i++) {
|
||||||
string name = "HotKeyBuild" + intToStr(i+1);
|
string name = "HotKeyBuild" + intToStr(i+1);
|
||||||
if(isKeyPressed(configKeys.getSDLKey(name.c_str()),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey(name.c_str()),key) == true) {
|
||||||
if(activeCommandType != NULL && activeCommandType->getClass() == ccBuild) {
|
if(activeCommandType != NULL && activeCommandType->getClass() == ccBuild) {
|
||||||
mouseDownDisplayUnitBuild(i);
|
mouseDownDisplayUnitBuild(i);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (i < commonCommands) mouseDownDisplayUnitSkills(i);
|
if (i < commonCommands) mouseDownDisplayUnitSkills(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::switchToNextDisplayColor(){
|
void Gui::switchToNextDisplayColor(){
|
||||||
|
@ -486,8 +486,8 @@ void Gui::giveOneClickOrders(){
|
||||||
result= commander->tryGiveCommand(&selection, activeCommandClass, Vec2i(0), (Unit*)NULL, queueKeyDown);
|
result= commander->tryGiveCommand(&selection, activeCommandClass, Vec2i(0), (Unit*)NULL, queueKeyDown);
|
||||||
}
|
}
|
||||||
addOrdersResultToConsole(activeCommandClass, result);
|
addOrdersResultToConsole(activeCommandClass, result);
|
||||||
activeCommandType= NULL;
|
activeCommandType= NULL;
|
||||||
activeCommandClass= ccStop;
|
activeCommandClass= ccStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::giveDefaultOrders(int x, int y) {
|
void Gui::giveDefaultOrders(int x, int y) {
|
||||||
|
@ -557,7 +557,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool queueKeyDown = isKeyDown(queueCommandKey);
|
bool queueKeyDown = isKeyDown(queueCommandKey);
|
||||||
//give orders to the units of this faction
|
//give orders to the units of this faction
|
||||||
if(selectingBuilding == false) {
|
if(selectingBuilding == false) {
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
result= commander->tryGiveCommand(&selection, activeCommandType,
|
result= commander->tryGiveCommand(&selection, activeCommandType,
|
||||||
|
@ -566,14 +566,14 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
|
||||||
else {
|
else {
|
||||||
result= commander->tryGiveCommand(&selection, activeCommandClass,
|
result= commander->tryGiveCommand(&selection, activeCommandClass,
|
||||||
targetPos, targetUnit,queueKeyDown);
|
targetPos, targetUnit,queueKeyDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//selecting building
|
//selecting building
|
||||||
result= commander->tryGiveCommand(&selection,
|
result= commander->tryGiveCommand(&selection,
|
||||||
activeCommandType, posObjWorld, choosenBuildingType,
|
activeCommandType, posObjWorld, choosenBuildingType,
|
||||||
selectedBuildingFacing,queueKeyDown);
|
selectedBuildingFacing,queueKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
//graphical result
|
//graphical result
|
||||||
addOrdersResultToConsole(activeCommandClass, result);
|
addOrdersResultToConsole(activeCommandClass, result);
|
||||||
|
@ -599,7 +599,7 @@ void Gui::centerCameraOnSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
||||||
const Faction *thisFaction = world->getThisFaction();
|
const Faction *thisFaction = world->getThisFaction();
|
||||||
const Unit* previousUnit = NULL;
|
const Unit* previousUnit = NULL;
|
||||||
bool previousFound = true;
|
bool previousFound = true;
|
||||||
|
|
||||||
|
@ -668,10 +668,10 @@ void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
|
||||||
|
|
||||||
//uniform selection
|
//uniform selection
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
const CommandType *ct = display.getCommandType(posDisplay);
|
const CommandType *ct = display.getCommandType(posDisplay);
|
||||||
|
|
||||||
// try to switch to next attack type
|
// try to switch to next attack type
|
||||||
if(activeCommandClass == ccAttack && activeCommandType!=NULL) {
|
if(activeCommandClass == ccAttack && activeCommandType!=NULL) {
|
||||||
|
|
||||||
int maxI = unit->getType()->getCommandTypeCount();
|
int maxI = unit->getType()->getCommandTypeCount();
|
||||||
int cmdTypeId = activeCommandType->getId();
|
int cmdTypeId = activeCommandType->getId();
|
||||||
|
@ -758,7 +758,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay) {
|
||||||
|
|
||||||
const BuildCommandType *bct = dynamic_cast<const BuildCommandType*>(activeCommandType);
|
const BuildCommandType *bct = dynamic_cast<const BuildCommandType*>(activeCommandType);
|
||||||
if(bct != NULL && bct->getBuildingCount() > posDisplay) {
|
if(bct != NULL && bct->getBuildingCount() > posDisplay) {
|
||||||
const UnitType *ut = bct->getBuilding(posDisplay);
|
const UnitType *ut = bct->getBuilding(posDisplay);
|
||||||
|
|
||||||
const Unit *unit = selection.getFrontUnit();
|
const Unit *unit = selection.getFrontUnit();
|
||||||
if(unit != NULL && unit->getFaction() != NULL) {
|
if(unit != NULL && unit->getFaction() != NULL) {
|
||||||
|
@ -768,7 +768,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay) {
|
||||||
|
|
||||||
choosenBuildingType = ut;
|
choosenBuildingType = ut;
|
||||||
selectingPos = true;
|
selectingPos = true;
|
||||||
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
selectedBuildingFacing = CardinalDir(CardinalDir::NORTH);
|
||||||
activePos = posDisplay;
|
activePos = posDisplay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -878,14 +878,14 @@ void Gui::computeInfoString(int posDisplay){
|
||||||
bool translatedValue= game->showTranslatedTechTree();
|
bool translatedValue= game->showTranslatedTechTree();
|
||||||
const UnitType *building=bct->getBuilding(posDisplay);
|
const UnitType *building=bct->getBuilding(posDisplay);
|
||||||
string str= lang.getString("BuildSpeed",(translatedValue == true ? "" : "english"))+": "+ intToStr(bct->getBuildSkillType()->getSpeed())+"\n";
|
string str= lang.getString("BuildSpeed",(translatedValue == true ? "" : "english"))+": "+ intToStr(bct->getBuildSkillType()->getSpeed())+"\n";
|
||||||
str+=""+Lang::getInstance().getString("TimeSteps",(translatedValue == true ? "" : "english"))+": "+intToStr(building->getProductionTime())+"\n";
|
str+=""+Lang::getInstance().getString("TimeSteps",(translatedValue == true ? "" : "english"))+": "+intToStr(building->getProductionTime())+"\n";
|
||||||
int64 speed=bct->getBuildSkillType()->getSpeed()+bct->getBuildSkillType()->getTotalSpeed(unit->getTotalUpgrade());
|
int64 speed=bct->getBuildSkillType()->getSpeed()+bct->getBuildSkillType()->getTotalSpeed(unit->getTotalUpgrade());
|
||||||
int64 time=building->getProductionTime();
|
int64 time=building->getProductionTime();
|
||||||
int64 seconds=time*100/speed;
|
int64 seconds=time*100/speed;
|
||||||
str+=""+Lang::getInstance().getString("Time",(translatedValue == true ? "" : "english"))+": "+intToStr(seconds);
|
str+=""+Lang::getInstance().getString("Time",(translatedValue == true ? "" : "english"))+": "+intToStr(seconds);
|
||||||
str+="\n\n";
|
str+="\n\n";
|
||||||
str+=building->getReqDesc(translatedValue);
|
str+=building->getReqDesc(translatedValue);
|
||||||
display.setInfoText(str);
|
display.setInfoText(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1059,7 @@ void Gui::computeDisplay(){
|
||||||
lastCommand++;
|
lastCommand++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonCommands = lastCommand;
|
commonCommands = lastCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (activeCommandType != NULL && activeCommandType->getClass() == ccBuild) {
|
else if (activeCommandType != NULL && activeCommandType->getClass() == ccBuild) {
|
||||||
|
@ -1145,9 +1145,9 @@ int Gui::computePosDisplay(int x, int y){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("computePosDisplay returning = %d\n",posDisplay);
|
//printf("computePosDisplay returning = %d\n",posDisplay);
|
||||||
|
|
||||||
|
@ -1156,64 +1156,64 @@ int Gui::computePosDisplay(int x, int y){
|
||||||
|
|
||||||
void Gui::addOrdersResultToConsole(CommandClass cc, std::pair<CommandResult,string> result) {
|
void Gui::addOrdersResultToConsole(CommandClass cc, std::pair<CommandResult,string> result) {
|
||||||
|
|
||||||
switch(result.first) {
|
switch(result.first) {
|
||||||
case crSuccess:
|
case crSuccess:
|
||||||
break;
|
break;
|
||||||
case crFailReqs:
|
case crFailReqs:
|
||||||
switch(cc){
|
switch(cc){
|
||||||
case ccBuild:
|
case ccBuild:
|
||||||
console->addStdMessage("BuildingNoReqs",result.second);
|
console->addStdMessage("BuildingNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccProduce:
|
case ccProduce:
|
||||||
console->addStdMessage("UnitNoReqs",result.second);
|
console->addStdMessage("UnitNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccMorph:
|
case ccMorph:
|
||||||
console->addStdMessage("MorphNoReqs",result.second);
|
console->addStdMessage("MorphNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
case ccUpgrade:
|
case ccUpgrade:
|
||||||
console->addStdMessage("UpgradeNoReqs",result.second);
|
console->addStdMessage("UpgradeNoReqs",result.second);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case crFailRes:
|
|
||||||
switch(cc){
|
|
||||||
case ccBuild:
|
|
||||||
console->addStdMessage("BuildingNoRes",result.second);
|
|
||||||
break;
|
|
||||||
case ccProduce:
|
|
||||||
console->addStdMessage("UnitNoRes",result.second);
|
|
||||||
break;
|
|
||||||
case ccMorph:
|
|
||||||
console->addStdMessage("MorphNoRes",result.second);
|
|
||||||
break;
|
|
||||||
case ccUpgrade:
|
|
||||||
console->addStdMessage("UpgradeNoRes",result.second);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case crFailRes:
|
||||||
|
switch(cc){
|
||||||
|
case ccBuild:
|
||||||
|
console->addStdMessage("BuildingNoRes",result.second);
|
||||||
|
break;
|
||||||
|
case ccProduce:
|
||||||
|
console->addStdMessage("UnitNoRes",result.second);
|
||||||
|
break;
|
||||||
|
case ccMorph:
|
||||||
|
console->addStdMessage("MorphNoRes",result.second);
|
||||||
|
break;
|
||||||
|
case ccUpgrade:
|
||||||
|
console->addStdMessage("UpgradeNoRes",result.second);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case crFailUndefined:
|
case crFailUndefined:
|
||||||
console->addStdMessage("InvalidOrder",result.second);
|
console->addStdMessage("InvalidOrder",result.second);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case crSomeFailed:
|
case crSomeFailed:
|
||||||
console->addStdMessage("SomeOrdersFailed",result.second);
|
console->addStdMessage("SomeOrdersFailed",result.second);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Gui::isSharedCommandClass(CommandClass commandClass){
|
bool Gui::isSharedCommandClass(CommandClass commandClass){
|
||||||
for(int i=0; i<selection.getCount(); ++i){
|
for(int i=0; i<selection.getCount(); ++i){
|
||||||
const Unit *unit= selection.getUnit(i);
|
const Unit *unit= selection.getUnit(i);
|
||||||
const CommandType *ct= unit->getType()->getFirstCtOfClass(commandClass);
|
const CommandType *ct= unit->getType()->getFirstCtOfClass(commandClass);
|
||||||
if(ct==NULL || !unit->getFaction()->reqsOk(ct))
|
if(ct==NULL || !unit->getFaction()->reqsOk(ct))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Gui
|
// class Gui
|
||||||
//
|
//
|
||||||
/// In game GUI
|
/// In game GUI
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
CommandClass activeCommandClass;
|
CommandClass activeCommandClass;
|
||||||
int activePos;
|
int activePos;
|
||||||
int lastPosDisplay;
|
int lastPosDisplay;
|
||||||
int commonCommands;
|
int commonCommands;
|
||||||
|
|
||||||
//composite
|
//composite
|
||||||
Display display;
|
Display display;
|
||||||
|
|
Loading…
Reference in New Issue