mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
queued commands are displayed in a better way
This commit is contained in:
parent
5d1f75ebe6
commit
9ce83ed21b
@ -1386,10 +1386,15 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
|
||||
}
|
||||
|
||||
//display
|
||||
if (metrics.isInDisplay(x, y) && !gui.isSelecting() && !gui.isSelectingPos()) {
|
||||
if ( !gui.isSelecting() && !gui.isSelectingPos()) {
|
||||
if (!gui.isSelectingPos()) {
|
||||
if(metrics.isInDisplay(x, y)){
|
||||
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
||||
}
|
||||
else {
|
||||
gui.mouseMoveOutsideDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastMousePos.x = mouseX;
|
||||
|
@ -105,6 +105,7 @@ Gui::Gui(){
|
||||
selectingPos= false;
|
||||
selectingMeetingPoint= false;
|
||||
activePos= invalidPos;
|
||||
lastPosDisplay= invalidPos;
|
||||
lastQuadCalcFrame=0;
|
||||
selectionCalculationFrameSkip=10;
|
||||
minQuadSize=20;
|
||||
@ -200,6 +201,10 @@ void Gui::mouseMoveDisplay(int x, int y) {
|
||||
computeInfoString(computePosDisplay(x, y));
|
||||
}
|
||||
|
||||
void Gui::mouseMoveOutsideDisplay() {
|
||||
computeInfoString(invalidPos);
|
||||
}
|
||||
|
||||
void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
|
||||
if(selectingPos) {
|
||||
//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){
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
display.setInfoText("");
|
||||
lastPosDisplay = posDisplay;
|
||||
|
||||
display.setInfoText(computeDefaultInfoString());
|
||||
|
||||
if(posDisplay!=invalidPos && selection.isCommandable()){
|
||||
if(!selectingBuilding){
|
||||
if(posDisplay==cancelPos){
|
||||
@ -621,6 +644,7 @@ void Gui::computeInfoString(int posDisplay){
|
||||
if(selection.isUniform()){
|
||||
const Unit *unit= selection.getFrontUnit();
|
||||
const CommandType *ct= display.getCommandType(posDisplay);
|
||||
|
||||
if(ct!=NULL){
|
||||
if(unit->getFaction()->reqsOk(ct)){
|
||||
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){
|
||||
|
@ -120,6 +120,7 @@ private:
|
||||
const CommandType *activeCommandType;
|
||||
CommandClass activeCommandClass;
|
||||
int activePos;
|
||||
int lastPosDisplay;
|
||||
|
||||
//composite
|
||||
Display display;
|
||||
@ -174,6 +175,7 @@ public:
|
||||
bool mouseValid(int x, int y);
|
||||
void mouseDownLeftDisplay(int x, int y);
|
||||
void mouseMoveDisplay(int x, int y);
|
||||
void mouseMoveOutsideDisplay();
|
||||
void mouseDownLeftGraphics(int x, int y, bool prepared);
|
||||
void mouseDownRightGraphics(int x, int y, bool prepared);
|
||||
void mouseUpLeftGraphics(int x, int y);
|
||||
@ -207,6 +209,7 @@ private:
|
||||
void mouseDownDisplayUnitSkills(int posDisplay);
|
||||
void mouseDownDisplayUnitBuild(int posDisplay);
|
||||
void computeInfoString(int posDisplay);
|
||||
string computeDefaultInfoString();
|
||||
void addOrdersResultToConsole(CommandClass cc, CommandResult rr);
|
||||
bool isSharedCommandClass(CommandClass commandClass);
|
||||
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();
|
||||
showUnitParticles = config.getBool("UnitParticles","true");
|
||||
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","1");
|
||||
maxQueuedCommandDisplayCount = config.getInt("MaxQueuedCommandDisplayCount","15");
|
||||
|
||||
lastPos= pos;
|
||||
progress= 0;
|
||||
@ -1403,6 +1403,25 @@ bool Unit::decHp(int i) {
|
||||
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 {
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
@ -1472,30 +1491,12 @@ string Unit::getDesc() const {
|
||||
|
||||
//command info
|
||||
if(commands.empty() == false) {
|
||||
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(maxQueuedCommandDisplayCount == 1) {
|
||||
str+= "\n" + ct->getName();
|
||||
if(commands.size()>1){
|
||||
str+="\n"+lang.get("OrdersOnQueue")+": "+intToStr(commands.size());
|
||||
str+= "\n" + commands.front()->getCommandType()->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
|
||||
if(getType()->getStoredResourceCount() > 0) {
|
||||
for(int i = 0; i < getType()->getStoredResourceCount(); ++i) {
|
||||
|
@ -454,6 +454,7 @@ public:
|
||||
void resetHighlight();
|
||||
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
|
||||
string getDesc() const;
|
||||
string getDescExtension() const;
|
||||
bool computeEp();
|
||||
bool computeHp();
|
||||
bool repair();
|
||||
|
Loading…
x
Reference in New Issue
Block a user