View Single Post
  #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:	403
Size:	24.6 KB
ID:	51433  
Reply With Quote