How to add a Admin tab?
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
How to add a Admin tab?
Hello. How can i add a Admin Tab to BZFlag 2.0.12?
Re: How to add a Admin tab?
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
"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
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
I meant the code for C++joevano wrote:What do you mean?
Last edited by Dontkillme on Tue Apr 07, 2009 11:00 am, edited 1 time in total.
Re: How to add a Admin tab?
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
"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
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
Thanks, it helped me. I added a tab for a friend too. But I cant open the two tabs. And Ijoevano 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
think if i can open them the messages won´t be in there.
Edit: Screenshoot:
Re: How to add a Admin tab?
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.
you are making a new feature, it will take some effort and thought on your part.
JeffM
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
I think somebody made a forum topic about this. But i don´t know who.
- clarahobbs
- Private First Class
- Posts: 272
- Joined: Thu Jan 10, 2008 1:45 am
- Location: The Fourth Dimension
Re: How to add a Admin tab?
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
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
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.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.
Re: How to add a Admin tab?
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...
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...
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
The key mapping! I knew I forgot somethingEnigma wrote:It looks like you just need to map some keys to the tabs.
The key mapping menu:
After Keymapping:
Tab for friend:
Admin Tab:
Ok I look into it.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.
Enigma wrote:There is another post about adding an admin tab somewhere, and I think I mentioned the function that handles this logic.
Ok I´m looking for the post.
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
I cant find it. Maybe its deleted?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.
Ok I´m looking for the post.
I cant find the line with the filter.Enigma wrote:You also have to change the logic that filters the messages and places them in the proper tabs.
Re: How to add a Admin tab?
From playing.cxx:
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.
Code: Select all
void addMessage(const Player *_player, const std::string& msg,
int mode, bool highlight, const char* oldColor)
{
Also look in ControlPanel.cxx and probably the header for that file.
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
Thanks!Enigma wrote:http://my.bzflag.org/bb/viewtopic.php?f=13&t=12691
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 ==========
Re: How to add a Admin tab?
You broke it. That is, you have syntax errors.
All I did was change
to
This is code from svn, so use integer constants instead of enumeration names (ControlPanel::MessageServer).
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());
}
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());
}
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
Then i get this errors:
I added the code
To playing.cxx, line 2571
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 ==========
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());
}
Re: How to add a Admin tab?
Like he said, you cannot use those enumeration names (ControlPanel::MessageChat, for example) because that is for trunk code. Use numbers.
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
Ok. I try it again with
Is that ok?
From ControlPanel.h:
[/size]
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());
}
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
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
I compiled it andDont kill my im a beginer wrote:Ok. I try it again withIs that ok?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()); }
From ControlPanel.h:
[/size]Code: Select all
enum MessageModes { MessageAllTabs = -2, MessageCurrent = -1, MessageAll = 0, MessageChat = 1, MessageServer = 2, MessageMisc = 3, MessageAdmin = 4, MessageAllejo = 5, MessageModeCount
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 ==========
Re: How to add a Admin tab?
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,
is better than
. 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.
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());
Code: Select all
addMessage(NULL, fullMsg, 2, false, oldcolor.c_str());
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.
- Dontkillme
- Private First Class
- Posts: 69
- Joined: Thu May 15, 2008 4:42 pm
- Location: Germany
Re: How to add a Admin tab?
Where can I download it?Enigma wrote:I am using the latest development code, not the 2.0 code.
-
- Private First Class
- Posts: 1400
- Joined: Sun Feb 06, 2005 5:40 pm
- Location: Somewhere over there.
Re: How to add a Admin tab?
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
If you do, check out http://my.bzflag.org/w/SVN
- clarahobbs
- Private First Class
- Posts: 272
- Joined: Thu Jan 10, 2008 1:45 am
- Location: The Fourth Dimension
Re: How to add a Admin tab?
This looks pretty cool! The only thing I'm concerned about is that the "allejo" tab seems to be hard coded...
FKA Ratfink
Re: How to add a Admin tab?
It's his client... I'm not concerned.