Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   F2 Console / Replacement for the F2 Log Window (https://forums.graalonline.com/forums/showthread.php?t=134260014)

Crow 07-31-2010 02:25 AM

F2 Console / Replacement for the F2 Log Window
 
1 Attachment(s)
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..

Soala 07-31-2010 03:33 AM

so old, so geek!

+rep

Fulg0reSama 07-31-2010 04:23 AM

Impressive :) This should be the new F2 default :P

Crow 07-31-2010 11:43 AM

Quote:

Originally Posted by Fulg0reSama (Post 1590603)
Impressive :) This should be the new F2 default :P

Interesting idea :p

salesman 07-31-2010 05:45 PM

crow so hot

Crono 07-31-2010 05:51 PM

nice ;)

nullify 08-01-2010 01:03 AM

Great work, +rep

Crow 08-01-2010 01:11 AM

Quote:

Originally Posted by salesman (Post 1590637)
crow so hot

Quote:

Originally Posted by Crono (Post 1590638)
nice ;)

Quote:

Originally Posted by nullify (Post 1590696)
Great work, +rep

Thanks! ^^

Nasgoroth 08-01-2010 05:15 PM

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

Crow 08-01-2010 05:23 PM

Quote:

Originally Posted by Nasgoroth (Post 1590818)
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 :p 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.

fowlplay4 08-01-2010 05:32 PM

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;
  }



Crow 08-01-2010 05:38 PM

Quote:

Originally Posted by fowlplay4 (Post 1590824)
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 :)

WhiteDragon 08-01-2010 05:55 PM

Evaluate GS2 expressions. ;)

kia345 08-01-2010 07:09 PM

Let's cut to the chase, will it open with "~"?

Crow 08-01-2010 07:23 PM

Quote:

Originally Posted by WhiteDragon (Post 1590826)
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 (Post 1590841)
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.


All times are GMT +2. The time now is 12:52 AM.

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