queued commands are displayed in a better way
This commit is contained in:
parent
5d1f75ebe6
commit
9ce83ed21b
|
@ -1386,9 +1386,14 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//display
|
//display
|
||||||
if (metrics.isInDisplay(x, y) && !gui.isSelecting() && !gui.isSelectingPos()) {
|
if ( !gui.isSelecting() && !gui.isSelectingPos()) {
|
||||||
if (!gui.isSelectingPos()) {
|
if (!gui.isSelectingPos()) {
|
||||||
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
if(metrics.isInDisplay(x, y)){
|
||||||
|
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gui.mouseMoveOutsideDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ Gui::Gui(){
|
||||||
selectingPos= false;
|
selectingPos= false;
|
||||||
selectingMeetingPoint= false;
|
selectingMeetingPoint= false;
|
||||||
activePos= invalidPos;
|
activePos= invalidPos;
|
||||||
|
lastPosDisplay= invalidPos;
|
||||||
lastQuadCalcFrame=0;
|
lastQuadCalcFrame=0;
|
||||||
selectionCalculationFrameSkip=10;
|
selectionCalculationFrameSkip=10;
|
||||||
minQuadSize=20;
|
minQuadSize=20;
|
||||||
|
@ -200,6 +201,10 @@ void Gui::mouseMoveDisplay(int x, int y) {
|
||||||
computeInfoString(computePosDisplay(x, y));
|
computeInfoString(computePosDisplay(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Gui::mouseMoveOutsideDisplay() {
|
||||||
|
computeInfoString(invalidPos);
|
||||||
|
}
|
||||||
|
|
||||||
void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
|
void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
|
||||||
if(selectingPos) {
|
if(selectingPos) {
|
||||||
//give standard orders
|
//give standard orders
|
||||||
|
@ -603,11 +608,29 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string Gui::computeDefaultInfoString(){
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
string result="";
|
||||||
|
|
||||||
|
if(selection.isCommandable() && selection.isUniform()){
|
||||||
|
// default is the description extension
|
||||||
|
result=selection.getFrontUnit()->getDescExtension();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Gui::computeInfoString(int posDisplay){
|
void Gui::computeInfoString(int posDisplay){
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
display.setInfoText("");
|
lastPosDisplay = posDisplay;
|
||||||
|
|
||||||
|
display.setInfoText(computeDefaultInfoString());
|
||||||
|
|
||||||
if(posDisplay!=invalidPos && selection.isCommandable()){
|
if(posDisplay!=invalidPos && selection.isCommandable()){
|
||||||
if(!selectingBuilding){
|
if(!selectingBuilding){
|
||||||
if(posDisplay==cancelPos){
|
if(posDisplay==cancelPos){
|
||||||
|
@ -621,6 +644,7 @@ void Gui::computeInfoString(int posDisplay){
|
||||||
if(selection.isUniform()){
|
if(selection.isUniform()){
|
||||||
const Unit *unit= selection.getFrontUnit();
|
const Unit *unit= selection.getFrontUnit();
|
||||||
const CommandType *ct= display.getCommandType(posDisplay);
|
const CommandType *ct= display.getCommandType(posDisplay);
|
||||||
|
|
||||||
if(ct!=NULL){
|
if(ct!=NULL){
|
||||||
if(unit->getFaction()->reqsOk(ct)){
|
if(unit->getFaction()->reqsOk(ct)){
|
||||||
display.setInfoText(ct->getDesc(unit->getTotalUpgrade()));
|
display.setInfoText(ct->getDesc(unit->getTotalUpgrade()));
|
||||||
|
@ -782,6 +806,11 @@ void Gui::computeDisplay(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refresh other things
|
||||||
|
computeInfoString(lastPosDisplay);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Gui::computePosDisplay(int x, int y){
|
int Gui::computePosDisplay(int x, int y){
|
||||||
|
|
|
@ -120,6 +120,7 @@ private:
|
||||||
const CommandType *activeCommandType;
|
const CommandType *activeCommandType;
|
||||||
CommandClass activeCommandClass;
|
CommandClass activeCommandClass;
|
||||||
int activePos;
|
int activePos;
|
||||||
|
int lastPosDisplay;
|
||||||
|
|
||||||
//composite
|
//composite
|
||||||
Display display;
|
Display display;
|
||||||
|
@ -174,6 +175,7 @@ public:
|
||||||
bool mouseValid(int x, int y);
|
bool mouseValid(int x, int y);
|
||||||
void mouseDownLeftDisplay(int x, int y);
|
void mouseDownLeftDisplay(int x, int y);
|
||||||
void mouseMoveDisplay(int x, int y);
|
void mouseMoveDisplay(int x, int y);
|
||||||
|
void mouseMoveOutsideDisplay();
|
||||||
void mouseDownLeftGraphics(int x, int y, bool prepared);
|
void mouseDownLeftGraphics(int x, int y, bool prepared);
|
||||||
void mouseDownRightGraphics(int x, int y, bool prepared);
|
void mouseDownRightGraphics(int x, int y, bool prepared);
|
||||||
void mouseUpLeftGraphics(int x, int y);
|
void mouseUpLeftGraphics(int x, int y);
|
||||||
|
@ -207,6 +209,7 @@ private:
|
||||||
void mouseDownDisplayUnitSkills(int posDisplay);
|
void mouseDownDisplayUnitSkills(int posDisplay);
|
||||||
void mouseDownDisplayUnitBuild(int posDisplay);
|
void mouseDownDisplayUnitBuild(int posDisplay);
|
||||||
void computeInfoString(int posDisplay);
|
void computeInfoString(int posDisplay);
|
||||||
|
string computeDefaultInfoString();
|
||||||
void addOrdersResultToConsole(CommandClass cc, CommandResult rr);
|
void addOrdersResultToConsole(CommandClass cc, CommandResult rr);
|
||||||
bool isSharedCommandClass(CommandClass commandClass);
|
bool isSharedCommandClass(CommandClass commandClass);
|
||||||
void computeSelected(bool doubleCkick,bool force);
|
void computeSelected(bool doubleCkick,bool force);
|
||||||
|
|
|
@ -235,7 +235,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
|
||||||
|
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
showUnitParticles = config.getBool("UnitParticles","true");
|
showUnitParticles = config.getBool("UnitParticles","true");
|
||||||
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","1");
|
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","15");
|
||||||
|
|
||||||
lastPos= pos;
|
lastPos= pos;
|
||||||
progress= 0;
|
progress= 0;
|
||||||
|
@ -1403,6 +1403,25 @@ bool Unit::decHp(int i) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Unit::getDescExtension() const{
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
string str= "\n";
|
||||||
|
|
||||||
|
if(commands.empty() == false && commands.size() > 1 ){
|
||||||
|
Commands::const_iterator it= commands.begin();
|
||||||
|
for(unsigned int i= 0; i < min((size_t) maxQueuedCommandDisplayCount, commands.size()); ++i){
|
||||||
|
const CommandType *ct= (*it)->getCommandType();
|
||||||
|
if(i == 0){
|
||||||
|
str+= "\n" + lang.get("OrdersOnQueue") + ": ";
|
||||||
|
}
|
||||||
|
str+= "\n#" + intToStr(i + 1) + " " + ct->getName();
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
string Unit::getDesc() const {
|
string Unit::getDesc() const {
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
@ -1471,31 +1490,13 @@ string Unit::getDesc() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
//command info
|
//command info
|
||||||
if(commands.empty() == false) {
|
if(commands.empty() == false) {
|
||||||
Commands::const_iterator it= commands.begin();
|
str+= "\n" + commands.front()->getCommandType()->getName();
|
||||||
for(unsigned int i = 0; i < min((size_t)maxQueuedCommandDisplayCount,commands.size()); ++i) {
|
if(commands.size() > 1) {
|
||||||
const CommandType *ct = (*it)->getCommandType();
|
str+= "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
|
||||||
if(maxQueuedCommandDisplayCount == 1) {
|
|
||||||
str+= "\n" + ct->getName();
|
|
||||||
if(commands.size()>1){
|
|
||||||
str+="\n"+lang.get("OrdersOnQueue")+": "+intToStr(commands.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(commands.size() == 1) {
|
|
||||||
str += "\n" + ct->getName();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(i == 0) {
|
|
||||||
str += "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
|
|
||||||
}
|
|
||||||
str += "\n#" + intToStr(i+1) + " " + ct->getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else{
|
||||||
//can store
|
//can store
|
||||||
if(getType()->getStoredResourceCount() > 0) {
|
if(getType()->getStoredResourceCount() > 0) {
|
||||||
for(int i = 0; i < getType()->getStoredResourceCount(); ++i) {
|
for(int i = 0; i < getType()->getStoredResourceCount(); ++i) {
|
||||||
|
|
|
@ -454,6 +454,7 @@ public:
|
||||||
void resetHighlight();
|
void resetHighlight();
|
||||||
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
|
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
|
||||||
string getDesc() const;
|
string getDesc() const;
|
||||||
|
string getDescExtension() const;
|
||||||
bool computeEp();
|
bool computeEp();
|
||||||
bool computeHp();
|
bool computeHp();
|
||||||
bool repair();
|
bool repair();
|
||||||
|
|
Loading…
Reference in New Issue