Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-31-2010, 02:25 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
F2 Console / Replacement for the F2 Log Window

A console-like thingy instead of some crappy GUI controls for the F2 log, who wouldn't like that? I do, now that I'm done with this small project It pretty much renders the regular F2 log useless, but I can live with that; the question is, can you? I don't care. After all, it's up to you if you use this or not.

F2 to toggle, as usual. Hit C when the console has focus to clear its contents. Arrow keys to scroll. Enjoy!

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
// "hide" F2LogWindow_Window
  // don't destroy, because we'd get a crapload of errors
  
F2LogWindow_Window.= -512;
  
  
sleep(0.1); // short delay; we seem need that
  
  
this.on      false;
  
this.init    true;
  
this.sliding false;
  
  
CreateControls();
  
AddOldMessages();
}

function 
CreateControls() {
  new 
GuiShowImgCtrl("F2Console") {
    
0= -256;
    
width GraalControl.width;
    
height 256;
    
    
polygon = { 00width0widthheight0height };
    
red green blue 0;
    
alpha 0.75;
    
    new 
GuiScrollCtrl("F2ConsoleScroll") {
      
0;
      
width GraalControl.width;
      
height 257;
      
      
useOwnProfile true;
      
profile.border 0;
      
profile.bitmap "";
      
profile.fillcolor = { 000};
      
      
hScrollBar "alwaysOff";
      
vScrollBar "alwaysOn";
      
      new 
GuiMLTextCtrl("F2ConsoleText") {
        
0;
        
width GraalControl.width 20;
        
height 257;
        
        
useOwnProfile true;
        
profile.fonttype "Courier";
        
profile.fontsize 12;
        
profile.fontcolor = { 255255255255 };
        
profile.fontcolorhl = { 000192 };
        
profile.fillcolorhl = { 255255255255 };
        
        
text "";
      }
    }
  }
}

// grab the messages from the existing f2log
// and add them to the new one
function AddOldMessages() {
  
temp.types = { "game""files""scripts",
                 
"net""graphics""sounds" };
  
  for (
temp.05i++) {
    
temp.msgs = ("F2LogWindow_Text" i).getText();
    
msgs ReplaceText(msgs"<font color=#007f00>""");
    
msgs ReplaceText(msgs"<font color=#ff00ff>""");
    
msgs ReplaceText(msgs"</font>""");
    
msgs ReplaceText(msgs"\\n"char(255));
    
    
temp.bits msgs.tokenize(char(255));
    for (
temp.btemp.bits) {
      
// fix that one bug..
      
if (b.starts("Loading tile definitions for server Login") &&
          
b.length() != 41)
        
b.substring(41, -1);
      
      
AddConsoleMessage(btypes[i]);
    }
  }
}

function 
AddConsoleMessage(msgmType) {
  
msg "[" mType "]" SPC msg;
  if (
F2ConsoleText.text != "")
    
msg "\n" msg;
  
  
F2ConsoleText.addText(msgfalse);
  
F2ConsoleText.scrollToBottom();
}

// receiving a message
function onLogMessage(msgrgbmType)
  
AddConsoleMessage(msgmType);

// open/close
function onKeyPressed(code) {
  if (
code != 113 || this.sliding || !this.init)
    return;
  
  if (!
this.on) {
    
this.on true;
    
this.sliding true;
    
    for (
temp.02i++) {
      
F2Console.+= 128;
      
sleep(0.05);
    }
    
    
this.sliding false;
    
F2ConsoleText.makeFirstResponder(true);
  } else {
    
this.on false;
    
this.sliding true;
    
    
GraalControl.makeFirstResponder(true);
    for (
temp.02i++) {
      
F2Console.-= 128;
      
sleep(0.05);
    }
    
    
this.sliding false;
  }
}

// clear
function F2ConsoleText.onKeyDown(codekey) {
  if (
key == "c")
    
F2ConsoleText.text "";
}

// Dusty's; thanks!
function ReplaceText(txtab) {
  if (
txt.pos(a) < 0)
    return 
txt;
  
  
temp.len a.length();
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0txtpos[0]);
  
  for (
temp.itemp.txtpos) {
    
temp.txt.substring(temp.len).pos(a);
    
temp.newtxt @= b
    
temp.newtxt @= txt.substring(temp.lentemp.p); 
  }
  
  return 
temp.newtxt

Edit: Oh, I forgot the screenshot..
Attached Thumbnails
Click image for larger version

Name:	f2console.png
Views:	396
Size:	24.6 KB
ID:	51433  
Reply With Quote
  #2  
Old 07-31-2010, 03:33 AM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
so old, so geek!

+rep
Reply With Quote
  #3  
Old 07-31-2010, 04:23 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Impressive This should be the new F2 default :P
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #4  
Old 07-31-2010, 11:43 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Fulg0reSama View Post
Impressive This should be the new F2 default :P
Interesting idea
Reply With Quote
  #5  
Old 07-31-2010, 05:45 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
crow so hot
__________________
Reply With Quote
  #6  
Old 07-31-2010, 05:51 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
nice
__________________
Reply With Quote
  #7  
Old 08-01-2010, 01:03 AM
nullify nullify is offline
Registerd Abuser
nullify's Avatar
Join Date: May 2004
Location: The cheese state.
Posts: 851
nullify has a spectacular aura about
Great work, +rep
Reply With Quote
  #8  
Old 08-01-2010, 01:11 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by salesman View Post
crow so hot
Quote:
Originally Posted by Crono View Post
nice
Quote:
Originally Posted by nullify View Post
Great work, +rep
Thanks!
Reply With Quote
  #9  
Old 08-01-2010, 05:15 PM
Nasgoroth Nasgoroth is offline
Spirit Crusher
Nasgoroth's Avatar
Join Date: May 2010
Location: Canada
Posts: 50
Nasgoroth will become famous soon enough
Send a message via MSN to Nasgoroth
I think you should put tabs for the file types, such as Files and Sounds, I often use F2 to steal some bodies when I'm on a new server :3 Other then that it's sexy Rep ASAP
__________________
If you choose not to decide, you still have made a choice
Reply With Quote
  #10  
Old 08-01-2010, 05:23 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Nasgoroth View Post
I think you should put tabs for the file types, such as Files and Sounds, I often use F2 to steal some bodies when I'm on a new server :3 Other then that it's sexy Rep ASAP
Tabs? No way This is supposed to look like a classic console, known from games like Quake. Everything is in there, and all messages have a small tag in front of them, so it shouldn't take you too long to find what you're looking for.
Reply With Quote
  #11  
Old 08-01-2010, 05:32 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Looks nice. I'd personally attach some code like this for the full console experience.

PHP Code:
//#CLIENTSIDE

function onCreated() {
  
// Console Input Control Flag
  
this.allowconsoleinput true;
}

// Console Input
function ChatBar.onAction() {
  if (
this.on && this.allowconsoleinput) {
    
handleInput(ChatBar.text);
    
ChatBar.text "";
  }
}

function 
handleInput(input) {
  
// Console commands, functions, etc.
  // Example Commands
  
temp.tokens input.tokenize();
  switch (
temp.tokens[0]) {
    case 
"echo":
      echo(
input.substring(5));
      break;
    case 
"reconnect":
      
serverwarp(getservername());
      break;
  }

__________________
Quote:
Reply With Quote
  #12  
Old 08-01-2010, 05:38 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by fowlplay4 View Post
Looks nice. I'd personally attach some code like this for the full console experience.

*snip*
Thought about doing that, and I already had a console-ish input field ready and working. But then I realized there's not exactly much to input anyway. Maybe I'll add that later though
Reply With Quote
  #13  
Old 08-01-2010, 05:55 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Evaluate GS2 expressions.
Reply With Quote
  #14  
Old 08-01-2010, 07:09 PM
kia345 kia345 is offline
z0rbi 4 life 🤘
kia345's Avatar
Join Date: Dec 2006
Location: delteria
Posts: 6,737
kia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond reputekia345 has a reputation beyond repute
Let's cut to the chase, will it open with "~"?
__________________
pojo
Reply With Quote
  #15  
Old 08-01-2010, 07:23 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by WhiteDragon View Post
Evaluate GS2 expressions.
Good idea! I will probably use one of the two eval() functions available on the code gallery.


Quote:
Originally Posted by kia345 View Post
Let's cut to the chase, will it open with "~"?
I actually thought about doing this. Problem is, I got a German keyboard, and we don't have the tilde as a key like this. For me, it's [Alt Gr] + [+] for a ~. It seems to share key codes with ^ though. At least that works in many other games. I'll give it a try.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.