scrollbars and other things ....; scrollbars always visible at the moment ; had some trouble with threads hopefully fixed now.
This commit is contained in:
parent
08d3f0bf60
commit
9b3e921888
|
@ -511,4 +511,109 @@ bool GraphicCheckBox::mouseClick(int x, int y){
|
|||
return result;
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class GraphicScrollBar
|
||||
// =====================================================
|
||||
|
||||
const int GraphicScrollBar::defThickness=20;
|
||||
const int GraphicScrollBar::defLength= 200;
|
||||
|
||||
void GraphicScrollBar::init(int x, int y, bool horizontal,int length, int thickness){
|
||||
GraphicComponent::init(x, y, horizontal?length:thickness,horizontal?thickness:length );
|
||||
this->horizontal=horizontal;
|
||||
this->elementCount=1;
|
||||
this->visibleSize=1;
|
||||
this->visibleStart=0;
|
||||
int visibleCompPosStart=0;
|
||||
int visibleCompPosEnd=length;
|
||||
lighted= false;
|
||||
}
|
||||
|
||||
bool GraphicScrollBar::mouseDown(int x, int y) {
|
||||
if(getVisible() && getEnabled() && getEditable())
|
||||
{
|
||||
if(mouseMove(x,y))
|
||||
{
|
||||
if( elementCount>visibleSize) {
|
||||
int pos;
|
||||
if(horizontal){
|
||||
pos=x-this->x;
|
||||
}
|
||||
else {
|
||||
// invert the clicked point ( y is from bottom to top normally )
|
||||
pos=getLength()-(y-this->y);
|
||||
}
|
||||
float partSize=(float)getLength()/(float)elementCount;
|
||||
float visiblePartSize=partSize*(float)visibleSize;
|
||||
float startPos=((float)pos)-visiblePartSize/2;
|
||||
|
||||
visibleStart=startPos/partSize;
|
||||
setVisibleStart(visibleStart);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GraphicScrollBar::setVisibleStart(int vs){
|
||||
visibleStart=vs;
|
||||
|
||||
if(visibleStart>elementCount-visibleSize) {
|
||||
visibleStart=elementCount-visibleSize;
|
||||
}
|
||||
if(visibleStart<0) {
|
||||
visibleStart=0;
|
||||
}
|
||||
float partSize=(float)getLength()/(float)elementCount;
|
||||
visibleCompPosStart=visibleStart*partSize;
|
||||
visibleCompPosEnd=visibleStart*partSize+visibleSize*partSize;
|
||||
if(visibleCompPosEnd>getLength()) {
|
||||
visibleCompPosEnd=getLength();
|
||||
}
|
||||
if(!horizontal) {
|
||||
// invert the display ( y is from bottom to top normally )
|
||||
visibleCompPosStart=getLength()-visibleCompPosStart;
|
||||
visibleCompPosEnd=getLength()-visibleCompPosEnd;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicScrollBar::setElementCount(int elementCount){
|
||||
this->elementCount=elementCount;
|
||||
setVisibleStart(getVisibleStart());
|
||||
}
|
||||
|
||||
void GraphicScrollBar::setVisibleSize(int visibleSize){
|
||||
this->visibleSize=visibleSize;
|
||||
setVisibleStart(getVisibleStart());
|
||||
}
|
||||
|
||||
|
||||
bool GraphicScrollBar::mouseClick(int x, int y){
|
||||
bool result=GraphicComponent::mouseClick( x, y);
|
||||
if(result)
|
||||
mouseDown( x, y);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool GraphicScrollBar::mouseMove(int x, int y){
|
||||
if(this->getVisible() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool b= GraphicComponent::mouseMove(x, y);
|
||||
lighted= b;
|
||||
return b;
|
||||
}
|
||||
|
||||
int GraphicScrollBar::getLength() {
|
||||
return horizontal?getW():getH();
|
||||
}
|
||||
|
||||
int GraphicScrollBar::getThickness() {
|
||||
return horizontal?getH():getW();
|
||||
}
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
|
||||
virtual void setX(int x) {this->x= x;}
|
||||
virtual void setY(int y) {this->y= y;}
|
||||
virtual void setW(int w) {this->w= w;}
|
||||
virtual void setH(int h) {this->h= h;}
|
||||
virtual void setText(const string &text) {this->text= text;}
|
||||
virtual void setFont(const Font2D *font) {this->font= font;}
|
||||
virtual void setEnabled(bool enabled) {this->enabled= enabled;}
|
||||
|
@ -249,5 +251,53 @@ public:
|
|||
virtual bool mouseClick(int x, int y);
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicScrollBar
|
||||
// ===========================================================
|
||||
|
||||
class GraphicScrollBar: public GraphicComponent {
|
||||
public:
|
||||
static const int defLength;
|
||||
static const int defThickness;
|
||||
|
||||
private:
|
||||
bool lighted;
|
||||
bool horizontal;
|
||||
int elementCount;
|
||||
int visibleSize;
|
||||
int visibleStart;
|
||||
|
||||
// position on component for renderer
|
||||
int visibleCompPosStart;
|
||||
int visibleCompPosEnd;
|
||||
|
||||
public:
|
||||
void init(int x, int y, bool horizontal,int length=defLength, int thickness=defThickness);
|
||||
virtual bool mouseDown(int x, int y);
|
||||
virtual bool mouseMove(int x, int y);
|
||||
virtual bool mouseClick(int x, int y);
|
||||
|
||||
|
||||
bool getHorizontal() const {return horizontal;}
|
||||
int getLength();
|
||||
void setLength(int length) {horizontal?setW(length):setH(length);}
|
||||
int getThickness();
|
||||
|
||||
|
||||
bool getLighted() const {return lighted;}
|
||||
void setLighted(bool lighted) {this->lighted= lighted;}
|
||||
|
||||
int getElementCount() const {return elementCount;}
|
||||
void setElementCount(int elementCount);
|
||||
int getVisibleSize() const {return visibleSize;}
|
||||
void setVisibleSize(int visibleSize);
|
||||
int getVisibleStart() const {return visibleStart;}
|
||||
int getVisibleEnd() const {return visibleStart+visibleSize>elementCount-1?elementCount-1: visibleStart+visibleSize-1;}
|
||||
void setVisibleStart(int visibleStart);
|
||||
|
||||
int getVisibleCompPosStart() const {return visibleCompPosStart;}
|
||||
int getVisibleCompPosEnd() const {return visibleCompPosEnd;}
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
#endif
|
||||
|
|
|
@ -1442,6 +1442,137 @@ void Renderer::renderLine(const GraphicLine *line) {
|
|||
glPopAttrib();
|
||||
}
|
||||
|
||||
void Renderer::renderScrollBar(const GraphicScrollBar *sb) {
|
||||
if(sb->getVisible() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x= sb->getX();
|
||||
int y= sb->getY();
|
||||
int h= sb->getH();
|
||||
int w= sb->getW();
|
||||
|
||||
const Vec3f disabledTextColor= Vec3f(0.25f,0.25f,0.25f);
|
||||
|
||||
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
|
||||
/////////////////////
|
||||
//background
|
||||
////////////////////
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
Texture2D *backTexture= coreData.getHorizontalLineTexture();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<Texture2DGl*>(backTexture)->getHandle());
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0.f, 0.f);
|
||||
glVertex2f(x, y);
|
||||
|
||||
glTexCoord2f(0.f, 1.f);
|
||||
glVertex2f(x, y+h);
|
||||
|
||||
glTexCoord2f(1.f, 0.f);
|
||||
glVertex2f(x+w, y);
|
||||
|
||||
glTexCoord2f(1.f, 1.f);
|
||||
glVertex2f(x+w, y+h);
|
||||
|
||||
glEnd();
|
||||
|
||||
////////////////////
|
||||
// selectBlock
|
||||
////////////////////
|
||||
|
||||
x= sb->getX();
|
||||
y= sb->getY();
|
||||
h= sb->getH();
|
||||
w= sb->getW();
|
||||
|
||||
if( sb->getHorizontal()) {
|
||||
x=x+sb->getVisibleCompPosStart();
|
||||
w=sb->getVisibleCompPosEnd()-sb->getVisibleCompPosStart();
|
||||
}
|
||||
else {
|
||||
y=y+sb->getVisibleCompPosStart();
|
||||
h=sb->getVisibleCompPosEnd()-sb->getVisibleCompPosStart();
|
||||
}
|
||||
|
||||
Texture2D *selectTexture= coreData.getButtonBigTexture();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<Texture2DGl*>(selectTexture)->getHandle());
|
||||
|
||||
//button
|
||||
Vec4f fontColor;
|
||||
//if(game!=NULL){
|
||||
// fontColor=game->getGui()->getDisplay()->getColor();
|
||||
// fontColor.w = GraphicComponent::getFade();
|
||||
//}
|
||||
//else {
|
||||
// white shadowed is default ( in the menu for example )
|
||||
fontColor=Vec4f(1.f, 1.f, 1.f, GraphicComponent::getFade());
|
||||
//}
|
||||
|
||||
//Vec4f color= Vec4f(1.f, 1.f, 1.f, GraphicComponent::getFade());
|
||||
Vec4f color= fontColor;
|
||||
glColor4fv(color.ptr());
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0.f, 0.f);
|
||||
glVertex2f(x, y);
|
||||
|
||||
glTexCoord2f(0.f, 1.f);
|
||||
glVertex2f(x, y+h);
|
||||
|
||||
glTexCoord2f(1.f, 0.f);
|
||||
glVertex2f(x+w, y);
|
||||
|
||||
glTexCoord2f(1.f, 1.f);
|
||||
glVertex2f(x+w, y+h);
|
||||
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
//lighting
|
||||
float anim= GraphicComponent::getAnim();
|
||||
if(anim>0.5f) anim= 1.f-anim;
|
||||
|
||||
if(sb->getLighted() && sb->getEditable()){
|
||||
const int lightSize= 0;
|
||||
const Vec4f color1= Vec4f(color.x, color.y, color.z, 0.1f+anim*0.5f);
|
||||
const Vec4f color2= Vec4f(color.x, color.y, color.z, 0.3f+anim);
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
||||
glColor4fv(color2.ptr());
|
||||
glVertex2f(x+w/2, y+h/2);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y-lightSize);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y-lightSize);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y+h+lightSize);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y+h+lightSize);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y+h+lightSize);
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y-lightSize);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void Renderer::renderListBox(const GraphicListBox *listBox) {
|
||||
if(listBox->getVisible() == false) {
|
||||
return;
|
||||
|
|
|
@ -328,6 +328,7 @@ public:
|
|||
void renderButton(const GraphicButton *button);
|
||||
void renderCheckBox(const GraphicCheckBox *box);
|
||||
void renderLine(const GraphicLine *line);
|
||||
void renderScrollBar(const GraphicScrollBar *sb);
|
||||
void renderListBox(const GraphicListBox *listBox);
|
||||
void renderMessageBox(const GraphicMessageBox *listBox);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
containerName = "MasterServer";
|
||||
updateFromMasterserverThread = NULL;
|
||||
ircClient = NULL;
|
||||
serverInfoString="empty";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -55,19 +56,33 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
consoleIRC.setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
consoleIRC.setLineHeight(18);
|
||||
|
||||
serverLinesToRender=9;
|
||||
serverLinesToRender=8;
|
||||
serverLinesLineHeight=25;
|
||||
serverLinesYBase=680;
|
||||
|
||||
userButtonsYBase=serverLinesYBase-(serverLinesToRender+2)*serverLinesLineHeight;
|
||||
userButtonsHeight=20;
|
||||
userButtonsWidth=150;
|
||||
userButtonsLineHeight=userButtonsHeight+2;
|
||||
userButtonsYBase=serverLinesYBase-(serverLinesToRender)*serverLinesLineHeight-90;
|
||||
userButtonsToRender=userButtonsYBase/userButtonsLineHeight;
|
||||
userButtonsXBase=1000-userButtonsWidth;
|
||||
|
||||
lines[0].init(0, userButtonsYBase+serverLinesLineHeight);
|
||||
lines[1].init(userButtonsXBase-5,0,5,userButtonsYBase+userButtonsLineHeight);
|
||||
userScrollBar.init(1000-20,0,false,200,20);
|
||||
userScrollBar.setLength(userButtonsYBase+userButtonsLineHeight);
|
||||
userScrollBar.setElementCount(0);
|
||||
userScrollBar.setVisibleSize(userButtonsToRender);
|
||||
userScrollBar.setVisibleStart(0);
|
||||
|
||||
userButtonsXBase=1000-userButtonsWidth-userScrollBar.getW();
|
||||
|
||||
serverScrollBar.init(1000-20,serverLinesYBase-serverLinesLineHeight*(serverLinesToRender-1),false,200,20);
|
||||
serverScrollBar.setLength(serverLinesLineHeight*serverLinesToRender);
|
||||
serverScrollBar.setElementCount(0);
|
||||
serverScrollBar.setVisibleSize(serverLinesToRender);
|
||||
serverScrollBar.setVisibleStart(0);
|
||||
|
||||
lines[0].init(0, userButtonsYBase+userButtonsLineHeight+serverLinesLineHeight);
|
||||
lines[1].init(userButtonsXBase-5,0,5,userButtonsYBase+2*userButtonsLineHeight);
|
||||
lines[1].setHorizontal(false);
|
||||
|
||||
autoRefreshTime=0;
|
||||
|
@ -129,18 +144,18 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
// binaryCompileDateLabel.setText(lang.get("MGBuildDateTime"));
|
||||
|
||||
//game info:
|
||||
i+=130;
|
||||
i+=80;
|
||||
serverTitleLabel.registerGraphicComponent(containerName,"serverTitleLabel");
|
||||
serverTitleLabel.init(i,startOffset-lineOffset);
|
||||
serverTitleLabel.setText(lang.get("MGGameTitle"));
|
||||
|
||||
i+=210;
|
||||
i+=200;
|
||||
ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel");
|
||||
ipAddressLabel.init(i,startOffset-lineOffset);
|
||||
ipAddressLabel.setText(lang.get("MGGameIP"));
|
||||
|
||||
//game setup info:
|
||||
i+=100;
|
||||
i+=120;
|
||||
techLabel.registerGraphicComponent(containerName,"techLabel");
|
||||
techLabel.init(i,startOffset-lineOffset);
|
||||
techLabel.setText(lang.get("TechTree"));
|
||||
|
@ -199,7 +214,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
autoRefreshTime=10*listBoxAutoRefresh.getSelectedItemIndex();
|
||||
|
||||
ircOnlinePeopleLabel.registerGraphicComponent(containerName,"ircOnlinePeopleLabel");
|
||||
ircOnlinePeopleLabel.init(userButtonsXBase,userButtonsYBase);
|
||||
ircOnlinePeopleLabel.init(userButtonsXBase,userButtonsYBase+userButtonsLineHeight);
|
||||
ircOnlinePeopleLabel.setText("IRC People Online:");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -364,6 +379,16 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(userScrollBar.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(serverScrollBar.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(buttonRefresh.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -440,7 +465,8 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
else {
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
bool clicked=false;
|
||||
for(int i=0; i<serverLines.size() && i<serverLinesToRender; ++i){
|
||||
if(!clicked && serverScrollBar.getElementCount()!=0){
|
||||
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
||||
if(serverLines[i]->buttonMouseClick(x, y)) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
clicked=true;
|
||||
|
@ -466,8 +492,9 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(!clicked){
|
||||
for(int i = 0; i < userButtons.size(); ++i) {
|
||||
}
|
||||
if(!clicked && userScrollBar.getElementCount()!=0){
|
||||
for(int i = userScrollBar.getVisibleStart(); i <= userScrollBar.getVisibleEnd(); ++i) {
|
||||
if(userButtons[i]->mouseClick(x, y)) {
|
||||
clicked=true;
|
||||
if(!chatManager.getEditEnabled())
|
||||
|
@ -495,14 +522,23 @@ void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
|
|||
buttonRefresh.mouseMove(x, y);
|
||||
buttonReturn.mouseMove(x, y);
|
||||
buttonCreateGame.mouseMove(x, y);
|
||||
if(ms->get(mbLeft)){
|
||||
userScrollBar.mouseDown(x, y);
|
||||
}
|
||||
else
|
||||
userScrollBar.mouseMove(x, y);
|
||||
listBoxAutoRefresh.mouseMove(x, y);
|
||||
|
||||
for(int i=0; i<serverLines.size() && i<serverLinesToRender; ++i){
|
||||
if(serverScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
||||
serverLines[i]->buttonMouseMove(x, y);
|
||||
}
|
||||
for(int i = 0; i < userButtons.size(); ++i) {
|
||||
}
|
||||
if(userScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = userScrollBar.getVisibleStart(); i <= userScrollBar.getVisibleEnd(); ++i) {
|
||||
userButtons[i]->mouseMove(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -554,9 +590,13 @@ void MenuStateMasterserver::render(){
|
|||
|
||||
const Vec4f titleLabelColorList = YELLOW;
|
||||
|
||||
for(int i=0; i<serverLines.size() && i<serverLinesToRender; ++i){
|
||||
if(serverScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
||||
serverLines[i]->render();
|
||||
}
|
||||
}
|
||||
renderer.renderScrollBar(&serverScrollBar);
|
||||
|
||||
for(int i=0; i<sizeof(lines) / sizeof(lines[0]); ++i){
|
||||
renderer.renderLine(&lines[i]);
|
||||
}
|
||||
|
@ -566,9 +606,12 @@ void MenuStateMasterserver::render(){
|
|||
renderer.renderButton(&buttonCreateGame);
|
||||
renderer.renderListBox(&listBoxAutoRefresh);
|
||||
|
||||
for(int i = 0; i < userButtons.size(); ++i) {
|
||||
if(userScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = userScrollBar.getVisibleStart(); i <= userScrollBar.getVisibleEnd(); ++i) {
|
||||
renderer.renderButton(userButtons[i]);
|
||||
}
|
||||
}
|
||||
renderer.renderScrollBar(&userScrollBar);
|
||||
|
||||
renderer.renderChatManager(&chatManager);
|
||||
renderer.renderConsole(&consoleIRC,true,true);
|
||||
|
@ -585,8 +628,7 @@ void MenuStateMasterserver::update() {
|
|||
}
|
||||
|
||||
// calculate button linepos:
|
||||
|
||||
setButtonLinePosition(serverLinesYBase-serverLinesToRender*serverLinesLineHeight);
|
||||
setButtonLinePosition(serverLinesYBase-(serverLinesToRender)*serverLinesLineHeight-30);
|
||||
|
||||
if(playServerFoundSound)
|
||||
{
|
||||
|
@ -608,6 +650,7 @@ void MenuStateMasterserver::update() {
|
|||
consoleIRC.update();
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient);
|
||||
safeMutexIRCPtr.Lock();
|
||||
if(ircClient != NULL) {
|
||||
std::vector<string> nickList = ircClient->getNickList();
|
||||
bool isNew=false;
|
||||
|
@ -628,15 +671,34 @@ void MenuStateMasterserver::update() {
|
|||
clearUserButtons();
|
||||
for(int i = 0; i < nickList.size(); ++i) {
|
||||
GraphicButton *button=new GraphicButton();
|
||||
button->init(userButtonsXBase,userButtonsYBase-userButtonsLineHeight*(i+1),userButtonsWidth,userButtonsHeight);
|
||||
button->init(userButtonsXBase,userButtonsYBase,userButtonsWidth,userButtonsHeight);
|
||||
//button->init(userButtonsXBase,userButtonsYBase-userButtonsLineHeight*i,userButtonsWidth,userButtonsHeight);
|
||||
button->setFont(CoreData::getInstance().getDisplayFontSmall());
|
||||
button->setText(nickList[i]);
|
||||
userButtons.push_back(button);
|
||||
}
|
||||
userScrollBar.setElementCount(userButtons.size());
|
||||
oldNickList=nickList;
|
||||
}
|
||||
if(userScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = userScrollBar.getVisibleStart(); i <= userScrollBar.getVisibleEnd(); ++i) {
|
||||
userButtons[i]->setY(userButtonsYBase-userButtonsLineHeight*(i-userScrollBar.getVisibleStart()));
|
||||
}
|
||||
}
|
||||
}
|
||||
safeMutexIRCPtr.ReleaseLock();
|
||||
if(serverInfoString!="empty")
|
||||
{
|
||||
rebuildServerLines(serverInfoString);
|
||||
serverInfoString="empty";
|
||||
}
|
||||
|
||||
serverScrollBar.setElementCount(serverLines.size());
|
||||
if(serverScrollBar.getElementCount()!=0 ) {
|
||||
for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) {
|
||||
serverLines[i]->setY(serverLinesYBase-serverLinesLineHeight*(i-serverScrollBar.getVisibleStart()));
|
||||
}
|
||||
}
|
||||
|
||||
if(threadedErrorMsg != "") {
|
||||
std::string sError = threadedErrorMsg;
|
||||
|
@ -686,8 +748,6 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needUpdateFromServer = false;
|
||||
int numberOfOldServerLines=serverLines.size();
|
||||
clearServerLines();
|
||||
safeMutex.ReleaseLock(true);
|
||||
|
||||
if(announcementLoaded == false) {
|
||||
|
@ -758,8 +818,38 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||
Lang &lang= Lang::getInstance();
|
||||
try {
|
||||
if(Config::getInstance().getString("Masterserver","") != "") {
|
||||
std::string serverInfo = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php");
|
||||
|
||||
std::string localServerInfoString = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php");
|
||||
serverInfoString=localServerInfoString;
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
serverInfoString=ex.what();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error during Internet game status update: [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
}
|
||||
|
||||
safeMutexPtr.Lock();
|
||||
if( updateFromMasterserverThread == NULL ||
|
||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
||||
safeMutexPtr.ReleaseLock();
|
||||
return;
|
||||
}
|
||||
safeMutexPtr.ReleaseLock();
|
||||
}
|
||||
catch(const exception &e){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
threadedErrorMsg = e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MenuStateMasterserver::rebuildServerLines(const string &serverInfo)
|
||||
{
|
||||
int numberOfOldServerLines=serverLines.size();
|
||||
clearServerLines();
|
||||
Lang &lang= Lang::getInstance();
|
||||
try {
|
||||
if(serverInfo != "") {
|
||||
std::vector<std::string> serverList;
|
||||
Tokenize(serverInfo,serverList,"\n");
|
||||
|
@ -804,18 +894,7 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||
sprintf(szBuf,"%s",masterServerInfo->getServerTitle().c_str());
|
||||
masterServerInfo->setServerTitle(szBuf);
|
||||
|
||||
safeMutexPtr.Lock();
|
||||
if( masterServerThreadInDeletion == true ||
|
||||
updateFromMasterserverThread == NULL ||
|
||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
||||
safeMutexPtr.ReleaseLock();
|
||||
return;
|
||||
}
|
||||
safeMutexPtr.ReleaseLock(true);
|
||||
|
||||
safeMutex.Lock();
|
||||
serverLines.push_back(new ServerLine( masterServerInfo, i, serverLinesYBase, serverLinesLineHeight, containerName));
|
||||
safeMutex.ReleaseLock(true);
|
||||
}
|
||||
else {
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -825,32 +904,16 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
labelTitle.setText("*** " + lang.get("AvailableServers") + " [" + ex.what() + "]");
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error during Internet game status update: [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
}
|
||||
|
||||
safeMutexPtr.Lock();
|
||||
if( updateFromMasterserverThread == NULL ||
|
||||
updateFromMasterserverThread->getQuitStatus() == true) {
|
||||
safeMutexPtr.ReleaseLock();
|
||||
return;
|
||||
}
|
||||
safeMutexPtr.ReleaseLock();
|
||||
|
||||
safeMutex.Lock();
|
||||
if(serverLines.size()>numberOfOldServerLines) {
|
||||
playServerFoundSound=true;
|
||||
}
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
catch(const exception &e){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
threadedErrorMsg = e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,9 +76,12 @@ private:
|
|||
SimpleTaskThread *updateFromMasterserverThread;
|
||||
bool playServerFoundSound;
|
||||
ServerLines serverLines;
|
||||
std::string serverInfoString;
|
||||
int serverLinesToRender;
|
||||
int serverLinesYBase;
|
||||
int serverLinesLineHeight;
|
||||
GraphicScrollBar userScrollBar;
|
||||
GraphicScrollBar serverScrollBar;
|
||||
UserButtons userButtons;
|
||||
UserButtons userButtonsToRemove;
|
||||
int userButtonsToRender;
|
||||
|
@ -130,6 +133,7 @@ private:
|
|||
void clearServerLines();
|
||||
void clearUserButtons();
|
||||
void updateServerInfo();
|
||||
void rebuildServerLines(const string &serverInfo);
|
||||
void cleanup();
|
||||
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count);
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
|
|||
this->containerName = containerName;
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
index=lineIndex;
|
||||
this->lineHeight=lineHeight;
|
||||
int lineOffset = lineHeight * lineIndex;
|
||||
masterServerInfo = *mServerInfo;
|
||||
|
@ -61,20 +60,20 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
|
|||
// binaryCompileDateLabel.setText(masterServerInfo.getBinaryCompileDate());
|
||||
|
||||
//game info:
|
||||
i+=130;
|
||||
i+=80;
|
||||
registeredObjNameList.push_back("serverTitleLabel" + intToStr(lineIndex));
|
||||
serverTitleLabel.registerGraphicComponent(containerName,"serverTitleLabel" + intToStr(lineIndex));
|
||||
serverTitleLabel.init(i,baseY-lineOffset);
|
||||
serverTitleLabel.setText(masterServerInfo.getServerTitle());
|
||||
|
||||
i+=210;
|
||||
i+=200;
|
||||
registeredObjNameList.push_back("ipAddressLabel" + intToStr(lineIndex));
|
||||
ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel" + intToStr(lineIndex));
|
||||
ipAddressLabel.init(i,baseY-lineOffset);
|
||||
ipAddressLabel.setText(masterServerInfo.getIpAddress());
|
||||
|
||||
//game setup info:
|
||||
i+=100;
|
||||
i+=120;
|
||||
registeredObjNameList.push_back("techLabel" + intToStr(lineIndex));
|
||||
techLabel.registerGraphicComponent(containerName,"techLabel" + intToStr(lineIndex));
|
||||
techLabel.init(i,baseY-lineOffset);
|
||||
|
@ -168,6 +167,7 @@ void ServerLine::render() {
|
|||
|
||||
//game info:
|
||||
renderer.renderLabel(&serverTitleLabel);
|
||||
if(!gameFull.getEnabled()){
|
||||
renderer.renderLabel(&ipAddressLabel);
|
||||
|
||||
//game setup info:
|
||||
|
@ -176,5 +176,30 @@ void ServerLine::render() {
|
|||
renderer.renderLabel(&tilesetLabel);
|
||||
renderer.renderLabel(&activeSlotsLabel);
|
||||
renderer.renderLabel(&externalConnectPort);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLine::setY(int y) {
|
||||
selectButton.setY(y);
|
||||
gameFull.setY(y);
|
||||
|
||||
//general info:
|
||||
glestVersionLabel.setY(y);
|
||||
platformLabel.setY(y);
|
||||
//binaryCompileDateLabel.setY(y);
|
||||
|
||||
//game info:
|
||||
serverTitleLabel.setY(y);
|
||||
ipAddressLabel.setY(y);
|
||||
|
||||
//game setup info:
|
||||
techLabel.setY(y);
|
||||
mapLabel.setY(y);
|
||||
tilesetLabel.setY(y);
|
||||
activeSlotsLabel.setY(y);
|
||||
|
||||
externalConnectPort.setY(y);
|
||||
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -29,7 +29,6 @@ class ServerLine {
|
|||
private:
|
||||
|
||||
MasterServerInfo masterServerInfo;
|
||||
int index;
|
||||
int lineHeight;
|
||||
int baseY;
|
||||
GraphicButton selectButton;
|
||||
|
@ -59,10 +58,10 @@ public:
|
|||
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, int lineHeight, const char *containerName);
|
||||
virtual ~ServerLine();
|
||||
MasterServerInfo *getMasterServerInfo() {return &masterServerInfo;}
|
||||
const int getIndex() const {return index;}
|
||||
const int getLineHeight() const {return lineHeight;}
|
||||
bool buttonMouseClick(int x, int y);
|
||||
bool buttonMouseMove(int x, int y);
|
||||
void setY(int y);
|
||||
//void setIndex(int value);
|
||||
void render();
|
||||
|
||||
|
|
Loading…
Reference in New Issue