Game Development Community

Backround picture in console?

by Luke Jones · in Torque Game Engine · 04/13/2004 (6:10 pm) · 8 replies

Anyone know how to go about adding a background picture to the console?
I dont really have enough knowledge to do it myself yet.

#1
04/13/2004 (6:42 pm)
I imagine you just add a bitmap to thae back behind the text
#2
04/13/2004 (9:36 pm)
It's a standard GUI element, so you can do just as Cameron suggests. Might be a bit tricky till you understand GUI stuff, though. :)
#3
04/13/2004 (9:50 pm)
Hoo-kay.
Thought it would be done that way.

Yep, still working hard a learning Torque, sorta know how i would do it, but havnt tried yet.
#4
04/13/2004 (11:03 pm)
Actualy, I need a few pointers...

Am I going to have to do this in script or at source level?
As in, am i going to need to make a new gui type, like guiScroll with bitmap support for the background?

Or can someone point me in the right direction for doing it in script?
#5
04/14/2004 (6:58 am)
Definatly script. Try applying a profile to it or putting a bitmap there yourself, and place it behind the text INSIDE the console ;)

If you go the profile route, I suggest you modify the already existing one.
#6
04/14/2004 (7:14 am)
This is the code to this console look
I think it is also resizing the console depending on the resolution... can't remember, it's pretty old ;)
// common/ui/ConsoleDlg.gui
//--- OBJECT WRITE BEGIN ---
new GuiControl(ConsoleDlg) {
   profile = "GuiDefaultProfile";
   
   new GuiBitmapCtrl(ConsoleBack) {
      profile = "GuiDefaultProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "2 3";
      extent = "624 337";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      bitmap = "./background0";
      wrap = "0";
   };

   new GuiTextCtrl(ConsoleTextCtrl) //GuiWindowCtrl()
   {
      profile = "GuiConsoleBackground";//"GuiWindowProfile";
      position = "0 0";
      extent = "640 370";
      //text = "Console";
      new GuiScrollCtrl(ConsoleScrollCtrl)
      {
         profile = "GuiScrollConsoleProfile";
         position = "0 0";
         extent = "640 350";
         hScrollBar = "alwaysOn";
         vScrollBar = "alwaysOn";
         horizSizing = "width";
         vertSizing = "height";
      
         new GuiConsole("testArrayCtrl")
         {
            profile = "GuiConsoleProfile";
            position = "0 0";
         };
      };
      
      new GuiConsoleEditCtrl("ConsoleEntry")
      {
         profile = "GuiTextEditProfile";
         position = "0 350";
         extent = "640 20";
         historySize = 20;
         altCommand = "ConsoleEntry::eval();";
         horizSizing = "width";
         vertSizing = "top";
      };
   };
};
//--- OBJECT WRITE END ---

$ConsoleActive = false;

function ConsoleEntry::eval()
{
   %text = ConsoleEntry.getValue();
   echo("==>" @ %text);
   eval(%text);
   ConsoleEntry.setValue("");
}

// When the console becomes active, make sure it's the right size
function ConsoleDlg::onWake()
{
   // Get the width and height of the current resolution
   %width = getWord( $pref::Video::resolution, 0 );
   %height = getWord( $pref::Video::resolution, 1 );
   // Now fix the console
   changeConsoleSize( %width, %height );
}
// Everytime the window changes size, this is called so that the 
// console will stretch across the whole screen
function changeConsoleSize( %width, %height )
{
   // We only want the console to take up 40% of the screen
   // leave some space for the controls on the right
   %width -= 90;
   %consoleHeight = 0.4*(%height);
   // Reset the main window.
   ConsoleTextCtrl.extent = %width @ " " @ %consoleHeight;
   // Reset the scroll control (20 less because of edit box)
   %consoleHeight -= 20;
   ConsoleScrollCtrl.extent = %width @ " " @ %consoleHeight;
   ConsoleBack.extent = %width-5 @ " " @ %consoleHeight-20;
   ConsoleBack.position = "2 3";
   // Reset the edit control
   ConsoleEntry.extent = %width @ " 20";
   ConsoleEntry.position = "0 " @ %consoleHeight;   
}
function ConsoleDlg::onSleep()
{
}

function ToggleConsole(%make)
{
   if (%make)
   {
      if ($ConsoleActive)
      {
         if ( $enableDirectInput )
            activateKeyboard();
         Canvas.popDialog(ConsoleDlg);
         if(PlayGui.isAwake())
         {
            Canvas.pushDialog( MainChatHud );
            chatHud.attach(HudMessageVector);
         }
         $ConsoleActive = false;
      }
      else
      {
         if ( $enableDirectInput )
            deactivateKeyboard();
         Canvas.popDialog( MainChatHud  );
         Canvas.pushDialog(ConsoleDlg, 99);
         $ConsoleActive = true;
      }
   }
}
#7
04/14/2004 (7:14 am)
... and here are the profiles used:
// common/ui/defaultProfiles.cs
if(!isObject(GuiConsoleProfile)) new GuiControlProfile ("GuiConsoleProfile")
{
   fontType = ($platform $= "macos") ? "Courier New" : "Arial Bold";
   //fontType = ($platform $= "macos") ? "Courier New" : "Lucida Console";
   fontSize = 14;
   fontColor = "255 255 255";
   fontColorHL = "0 0 0";
   //fontColor = "0 0 0";
   //fontColorHL = "130 130 130";
   fontColorNA = "255 0 0";
   fontColors[6] = "50 50 50";
   fontColors[7] = "50 50 0";  
   fontColors[8] = "0 0 50"; 
   fontColors[9] = "0 50 0";   
};

if(!isObject(GuiScrollConsoleProfile)) new GuiControlProfile (GuiScrollConsoleProfile)
{
   
   //opaque = true;
   //fillColor = "125 125 125";
   
   border = 3;
   borderThickness = 2;
   borderColor = "0 0 0";
   bitmap = ($platform $= "macos") ? "./osxScroll" : "./darkScroll";
   hasBitmapArray = true;
};
#8
04/14/2004 (3:04 pm)
Hmm... so i was going in the right direction.
Thanks Stefan, I'd pretty much done it that way, except for
new GuiTextCtrl(ConsoleTextCtrl) //GuiWindowCtrl()
   {
      profile = "GuiConsoleBackground";//"GuiWindowProfile";

Thanks for everyones help.