How to add a Admin tab?

Questions or HOWTOs about the above? Post 'em here...
User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

How to add a Admin tab?

Post by Dontkillme » Sat Apr 04, 2009 10:13 am

Hello. How can i add a Admin Tab to BZFlag 2.0.12?

User avatar
joevano
General
General
Posts: 1863
Joined: Sat Jun 18, 2005 1:08 pm
Location: South Bend, Indiana, USA

Re: How to add a Admin tab?

Post by joevano » Sat Apr 04, 2009 10:46 am

What do you mean? You can't add tabs to the chat window without altering the source code...
There is nothing worse than aggressive stupidity. -- Johann Wolfgang von Goethe
"How many legs does a dog have if you call his tail a leg? Four. Calling a tail a leg doesn't make it a leg." -- Abraham Lincoln

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Sat Apr 04, 2009 11:54 am

joevano wrote:What do you mean?
I meant the code for C++
Last edited by Dontkillme on Tue Apr 07, 2009 11:00 am, edited 1 time in total.

User avatar
joevano
General
General
Posts: 1863
Joined: Sat Jun 18, 2005 1:08 pm
Location: South Bend, Indiana, USA

Re: How to add a Admin tab?

Post by joevano » Sat Apr 04, 2009 12:33 pm

Here is the patch that blast wrote to actually ADD the tabs. It might give you a clue,it is an old, old patch... but it may help. http://sourceforge.net/tracker/index.ph ... tid=303248
There is nothing worse than aggressive stupidity. -- Johann Wolfgang von Goethe
"How many legs does a dog have if you call his tail a leg? Four. Calling a tail a leg doesn't make it a leg." -- Abraham Lincoln

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Sat Apr 04, 2009 7:37 pm

joevano wrote:Here is the patch that blast wrote to actually ADD the tabs. It might give you a clue,it is an old, old patch... but it may help. http://sourceforge.net/tracker/index.ph ... tid=303248
Thanks, it helped me. I added a tab for a friend too. But I cant open the two tabs. And I
think if i can open them the messages won´t be in there.

Edit: Screenshoot:
Image

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5182
Joined: Fri Dec 13, 2002 4:11 am
Location: https://github.com/OmniTanks
Contact:

Re: How to add a Admin tab?

Post by JeffM » Sat Apr 04, 2009 8:09 pm

well yes, you have to do the development work to write the input code to swap tabs.

you are making a new feature, it will take some effort and thought on your part.

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Sun Apr 05, 2009 8:56 am

I think somebody made a forum topic about this. But i don´t know who.

User avatar
clarahobbs
Private First Class
Private First Class
Posts: 272
Joined: Thu Jan 10, 2008 1:45 am
Location: The Fourth Dimension

Re: How to add a Admin tab?

Post by clarahobbs » Sun Apr 05, 2009 4:21 pm

That looks like it could be a pretty cool feature! It could be useful to make the "friend" tab not appear until someone sends you about 5 messages (exact number could be configurable). Then it makes a new tab for that player. That would be a lot more complicated, though.
FKA Ratfink

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Sun Apr 05, 2009 5:06 pm

Ratfink wrote:That looks like it could be a pretty cool feature! It could be useful to make the "friend" tab not appear until someone sends you about 5 messages (exact number could be configurable). Then it makes a new tab for that player. That would be a lot more complicated, though.
Hmm... I think that is an good idea but i don´t know a lot about C++. And i cant open the two tabs. Maybe somebody who knows a lot about C++ can help me.

Enigma
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Re: How to add a Admin tab?

Post by Enigma » Tue Apr 07, 2009 3:36 am

Yeah, I did this once. I won't be able to walk you through every step, mostly because I am very busy right now, with the semester coming to a close and all. I can help a little it though.

It looks like you just need to map some keys to the tabs. There are like five source files you need to edit. If you look at the patch, you can see how it's done. If you do it right, you'll have an option on the key mapping menu for mapping your new admin tab.

You also have to change the logic that filters the messages and places them in the proper tabs. this is in playing.cxx. There is another post about adding an admin tab somewhere, and I think I mentioned the function that handles this logic.

Pretty much everything you need to know can be found in the patch: source files, line numbers, code examples, etc...

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Tue Apr 07, 2009 8:14 am

Enigma wrote:It looks like you just need to map some keys to the tabs.
:doh: The key mapping! I knew I forgot something
The key mapping menu:
Image
After Keymapping:
Image
Tab for friend:
Image
Admin Tab:
Image
Enigma wrote:You also have to change the logic that filters the messages and places them in the proper tabs. this is in playing.cxx.
Ok I look into it.
Enigma wrote:There is another post about adding an admin tab somewhere, and I think I mentioned the function that handles this logic.
Image
Ok I´m looking for the post.

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Tue Apr 07, 2009 11:22 am

Dont kill my im a beginer wrote:
Enigma wrote:There is another post about adding an admin tab somewhere, and I think I mentioned the function that handles this logic.
Image
Ok I´m looking for the post.
I cant find it. Maybe its deleted?
Enigma wrote:You also have to change the logic that filters the messages and places them in the proper tabs.
I cant find the line with the filter.

User avatar
blast
General
General
Posts: 4756
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: How to add a Admin tab?

Post by blast » Tue Apr 07, 2009 6:04 pm

From playing.cxx:

Code: Select all

void            addMessage(const Player *_player, const std::string& msg,
                           int mode, bool highlight, const char* oldColor)
{
addMessage is used to add a message to the panel, and you can control which tab is used with the 'mode'.

Also look in ControlPanel.cxx and probably the header for that file.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image

Enigma
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Re: How to add a Admin tab?

Post by Enigma » Tue Apr 07, 2009 8:19 pm


User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Wed Apr 08, 2009 7:25 am

Thanks! :D
Where can i add the code?
I get all the time errors:

Code: Select all

------ Build started: Project: date, Configuration: Release_pdcurses Win32 ------
Compiling...
buildDate.cxx
Creating library...
Touching buildDate.cxx...
Build log was saved at "file://c:\Dokumente und Einstellungen\Desktop\\bzflag-2.0.12\bzflag-2.0.12\win32\VC8\Release_pdcurses\BuildLog.htm"
date - 0 error(s), 0 warning(s)
------ Build started: Project: bzflag, Configuration: Release_pdcurses Win32 ------
Compiling...
playing.cxx
..\..\src\bzflag\playing.cxx(1336) : warning C4091: '' : ignored on left of 'void' when no variable is declared
..\..\src\bzflag\playing.cxx(1336) : error C2143: syntax error : missing ';' before 'if'
..\..\src\bzflag\playing.cxx(1336) : error C2059: syntax error : 'if'
..\..\src\bzflag\playing.cxx(1338) : error C2059: syntax error : 'else'
..\..\src\bzflag\playing.cxx(1340) : error C2059: syntax error : 'else'
..\..\src\bzflag\playing.cxx(1342) : error C2059: syntax error : '}'
..\..\src\bzflag\playing.cxx(1342) : error C2143: syntax error : missing ';' before '}'
..\..\src\bzflag\playing.cxx(1342) : error C2059: syntax error : '}'
..\..\src\bzflag\playing.cxx(1345) : error C2143: syntax error : missing ';' before '{'
..\..\src\bzflag\playing.cxx(1345) : error C2447: '{' : missing function header (old-style formal list?)
..\..\src\bzflag\playing.cxx(1917) : error C3861: 'removePlayer': identifier not found
..\..\src\bzflag\playing.cxx(2820) : error C3861: 'removePlayer': identifier not found
Build log was saved at "file://c:\Dokumente und Einstellungen\Desktop\bzflag-2.0.12\bzflag-2.0.12\win32\VC8\Release_pdcurses\BuildLog.htm"
bzflag - 11 error(s), 1 warning(s)
========== Build: 1 succeeded, 1 failed, 13 up-to-date, 0 skipped ==========

Enigma
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Re: How to add a Admin tab?

Post by Enigma » Wed Apr 08, 2009 11:31 pm

You broke it. That is, you have syntax errors.

All I did was change

Code: Select all

    
if (fromServer) {
      addMessage(NULL, fullMsg, ControlPanel::MessageServer, false, oldcolor.c_str());
} else {
      addMessage(NULL, fullMsg, ControlPanel::MessageChat, false, oldcolor.c_str());
}
to

Code: Select all

if (fromServer) {
      addMessage(NULL, fullMsg, ControlPanel::MessageServer, false, oldcolor.c_str());
} else if (toAdmin) {
     addMessage(NULL, fullMsg, ControlPanel::MessageAdmin, false, oldcolor.c_str());
} else {
      addMessage(NULL, fullMsg, ControlPanel::MessageChat, false, oldcolor.c_str());
}
This is code from svn, so use integer constants instead of enumeration names (ControlPanel::MessageServer).

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Thu Apr 09, 2009 9:11 am

Then i get this errors:

Code: Select all

------ Build started: Project: date, Configuration: Release_pdcurses Win32 ------
Compiling...
buildDate.cxx
Creating library...
Touching buildDate.cxx...
Build log was saved at "file://c:\Dokumente und Einstellungen\Desktop\bzflag-2.0.12\bzflag-2.0.12\win32\VC8\Release_pdcurses\BuildLog.htm"
date - 0 error(s), 0 warning(s)
------ Build started: Project: bzflag, Configuration: Release_pdcurses Win32 ------
Compiling...
playing.cxx
..\..\src\bzflag\playing.cxx(2572) : error C2065: 'fromServer' : undeclared identifier
..\..\src\bzflag\playing.cxx(2573) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2573) : error C2248: 'MessageServer' : cannot access private enumerator declared in class 'ControlPanel'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(84) : see declaration of 'MessageServer'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(46) : see declaration of 'ControlPanel'
..\..\src\bzflag\playing.cxx(2573) : error C2065: 'oldcolor' : undeclared identifier
..\..\src\bzflag\playing.cxx(2573) : error C2228: left of '.c_str' must have class/struct/union
        type is ''unknown-type''
..\..\src\bzflag\playing.cxx(2574) : error C2065: 'toAdmin' : undeclared identifier
..\..\src\bzflag\playing.cxx(2575) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2575) : error C2248: 'MessageAdmin' : cannot access private enumerator declared in class 'ControlPanel'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(86) : see declaration of 'MessageAdmin'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(46) : see declaration of 'ControlPanel'
..\..\src\bzflag\playing.cxx(2575) : error C2065: 'oldcolor' : undeclared identifier
..\..\src\bzflag\playing.cxx(2575) : error C2228: left of '.c_str' must have class/struct/union
        type is ''unknown-type''
..\..\src\bzflag\playing.cxx(2577) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2577) : error C2248: 'MessageChat' : cannot access private enumerator declared in class 'ControlPanel'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(83) : see declaration of 'MessageChat'
        c:\dokumente und einstellungen\desktop\bzflag-2.0.12\bzflag-2.0.12\src\bzflag\ControlPanel.h(46) : see declaration of 'ControlPanel'
..\..\src\bzflag\playing.cxx(2577) : error C2065: 'oldcolor' : undeclared identifier
..\..\src\bzflag\playing.cxx(2577) : error C2228: left of '.c_str' must have class/struct/union
        type is ''unknown-type''
Build log was saved at "file://c:\Dokumente und Einstellungen\Desktop\bzflag-2.0.12\bzflag-2.0.12\win32\VC8\Release_pdcurses\BuildLog.htm"
bzflag - 14 error(s), 0 warning(s)
========== Build: 1 succeeded, 1 failed, 13 up-to-date, 0 skipped ==========
I added the code

Code: Select all

if (fromServer) {
      addMessage(NULL, fullMsg, ControlPanel::MessageServer, false, oldcolor.c_str());
} else if (toAdmin) {
     addMessage(NULL, fullMsg, ControlPanel::MessageAdmin, false, oldcolor.c_str());
} else {
      addMessage(NULL, fullMsg, ControlPanel::MessageChat, false, oldcolor.c_str());
}
To playing.cxx, line 2571
Image

User avatar
blast
General
General
Posts: 4756
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: How to add a Admin tab?

Post by blast » Thu Apr 09, 2009 1:13 pm

Like he said, you cannot use those enumeration names (ControlPanel::MessageChat, for example) because that is for trunk code. Use numbers.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Thu Apr 09, 2009 1:22 pm

Ok. I try it again with

Code: Select all

if (fromServer) {
      addMessage(NULL, fullMsg, ControlPanel::2, false, oldcolor.c_str());
} else if (toAdmin) {
     addMessage(NULL, fullMsg, ControlPanel::4, false, oldcolor.c_str());
} else {
      addMessage(NULL, fullMsg, ControlPanel::1, false, oldcolor.c_str());
}
Is that ok?

From ControlPanel.h:

Code: Select all

    enum MessageModes {
      MessageAllTabs = -2,
      MessageCurrent = -1,
      MessageAll     = 0,
      MessageChat    = 1,
      MessageServer  = 2,
      MessageMisc    = 3,
      MessageAdmin   = 4,
      MessageAllejo  = 5,
      MessageModeCount
[/size]

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Thu Apr 09, 2009 3:46 pm

Dont kill my im a beginer wrote:Ok. I try it again with

Code: Select all

if (fromServer) {
      addMessage(NULL, fullMsg, ControlPanel::2, false, oldcolor.c_str());
} else if (toAdmin) {
     addMessage(NULL, fullMsg, ControlPanel::4, false, oldcolor.c_str());
} else {
      addMessage(NULL, fullMsg, ControlPanel::1, false, oldcolor.c_str());
}
Is that ok?

From ControlPanel.h:

Code: Select all

    enum MessageModes {
      MessageAllTabs = -2,
      MessageCurrent = -1,
      MessageAll     = 0,
      MessageChat    = 1,
      MessageServer  = 2,
      MessageMisc    = 3,
      MessageAdmin   = 4,
      MessageAllejo  = 5,
      MessageModeCount
[/size]
I compiled it and

Code: Select all

----- Build started: Project: bzflag, Configuration: Release_pdcurses Win32 ------
Compiling...
playing.cxx
..\..\src\bzflag\playing.cxx(2558) : error C2065: 'fromServer' : undeclared identifier
..\..\src\bzflag\playing.cxx(2559) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2559) : error C2589: 'constant' : illegal token on right side of '::'
..\..\src\bzflag\playing.cxx(2559) : error C2059: syntax error : '::'
..\..\src\bzflag\playing.cxx(2560) : error C2065: 'toAdmin' : undeclared identifier
..\..\src\bzflag\playing.cxx(2561) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2561) : error C2589: 'constant' : illegal token on right side of '::'
..\..\src\bzflag\playing.cxx(2561) : error C2059: syntax error : '::'
..\..\src\bzflag\playing.cxx(2563) : error C2065: 'fullMsg' : undeclared identifier
..\..\src\bzflag\playing.cxx(2563) : error C2589: 'constant' : illegal token on right side of '::'
..\..\src\bzflag\playing.cxx(2563) : error C2059: syntax error : '::'
Build log was saved at "file://c:\Dokumente und Einstellungen\Desktop\bzflag-2.0.12\bzflag-2.0.12\win32\VC8\Release_pdcurses\BuildLog.htm"
bzflag - 11 error(s), 0 warning(s)
========== Build: 1 succeeded, 1 failed, 13 up-to-date, 0 skipped ==========
Is there maybe a special place, where i have to add it?

Enigma
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Re: How to add a Admin tab?

Post by Enigma » Fri Apr 10, 2009 3:00 am

OK......

Enumerations are just named integers. You can either use the enumeration name or an integer constant instead. If you have an enumeration, then it is better to use enumeration names instead of integers, as it expresses intent. For instance,

Code: Select all

addMessage(NULL, fullMsg, ControlPanel::MessageServer, false, oldcolor.c_str());
is better than

Code: Select all

addMessage(NULL, fullMsg, 2, false, oldcolor.c_str());
. Why is the first code example better than the second? Well, when reading the code, you might ask, "what does 2 mean?" On the other hand, it is clear what ControlPanel::MessageServer does. It is easier to remember as well. There are probably more reasons, but I don't want to think about it anymore.

Additionally, integer constants do not have class-scope. That is, they are not declared/defined in the class like the MessageModes enumeration is. As a result, you need to use the scope resolution operator (::) to use MessageModes outside of the class (ex: ControlPanel::MessageModes). Using the scope resolution operator with integers doesn't make any sense (ex: ControlPanel::1).

As I already explained before, I am using the latest development code, not the 2.0 code. Thus, it is different. How is it different? Last I checked, you cannot use ControlPanel::MessageModes outside of the ControlPanel class because it has private access only. So use the integer constants, and buy a programming book. Don't forget to read it.

Anyways, named constants rock! Just imagine life without them. :cry:

User avatar
Dontkillme
Private First Class
Private First Class
Posts: 69
Joined: Thu May 15, 2008 4:42 pm
Location: Germany

Re: How to add a Admin tab?

Post by Dontkillme » Fri Apr 10, 2009 1:03 pm

Enigma wrote:I am using the latest development code, not the 2.0 code.
Where can I download it?

User avatar
khazhyk
Private First Class
Private First Class
Posts: 1400
Joined: Sun Feb 06, 2005 5:40 pm
Location: Somewhere over there.
Contact:

Re: How to add a Admin tab?

Post by khazhyk » Fri Apr 10, 2009 1:55 pm

The latest dev code will not work with 2.0 servers, so you probably don't want it.
If you do, check out http://my.bzflag.org/w/SVN
Image

User avatar
clarahobbs
Private First Class
Private First Class
Posts: 272
Joined: Thu Jan 10, 2008 1:45 am
Location: The Fourth Dimension

Re: How to add a Admin tab?

Post by clarahobbs » Fri Apr 10, 2009 11:56 pm

This looks pretty cool! The only thing I'm concerned about is that the "allejo" tab seems to be hard coded...
FKA Ratfink

Enigma
Private First Class
Private First Class
Posts: 211
Joined: Sat Apr 23, 2005 3:13 am

Re: How to add a Admin tab?

Post by Enigma » Sat Apr 11, 2009 2:08 am

It's his client... I'm not concerned.

Post Reply