Creating a window for a mutator

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

Creating a window for a mutator

Postby Ayleth » Fri Mar 02, 07 5:02 am

basically, i want to make a window for my admintool project... right now its using an akward combination of clicks and keys to access the different functions, but now that i think about it, a nicely organised window created via "mutate admin" or some jazz like that would be 100% better. I took a look at the viewable source from the dxmapvote mutator, but all the UnknownFunction119's etc, are all throwing me for a loop. does anyone have an idea what to do? Thx.
¨‘°ºMåsåmµñ£º°‘¨
˙•●●ĊђασsΪηcǻяйαѓε●●•˙
jason.unger@gmail.com
User avatar
Ayleth
Regular
 
Posts: 313
Joined: Sun Jul 09, 06 7:27 pm
Location: 6 feet under. and trying to get out!

Postby Dae » Fri Mar 02, 07 5:09 pm

That's how I spawn a window in my AntiTKMutator:

From mutator class:
Code: Select all
local ExternalActor EA;
EA = Other.Spawn(class'ExternalActor', Other);
EA.AskPlayer(..., ...);
EA.Destroy();

Comments:
AskPlayer() is my own function, you don't need it. It's being called from ExternalActor.uc

"Other" in the second line is a player which will "own" the window. If you're going to use this piece of code inside Mutate(), it will be just Player.

From ExternalActor.uc:
Code: Select all
class ExternalActor extends Actor;
replication
{
reliable if (!bDemoRecording && (Role == ROLE_Authority))
   AskPlayer;
}

simulated final function AskPlayer(DeusExPlayer Player, DeusExPlayer Killer)
{
   local DeusExRootWindow root;
   local AskingMBW AMBW;
   if (Player != None)
   {
      Player.InitRootWindow();
      root = DeusExRootWindow(Player.rootWindow);
      if (root != None)
      {
         AMBW = AskingMBW(root.InvokeUIScreen(Class'AskingMBW', True));
         AMBW.SetMessageText("You have been killed by a member|nof your team, "$Killer.PlayerReplicationInfo.PlayerName$". Was this a deliberate act?");
         root.ShowCursor(True);
      }
   }
}

defaultproperties
{
   bHidden=True
}


AskingMBW.uc (basically, a big copypasta of one of windows from DeusEx.u):
Code: Select all
class AskingMBW expands MenuUIWindow;

enum EMessageBoxModes
{
   MB_YesNo,
   MB_OK,
};

enum EMessageBoxResults
{
   MR_Yes,
   MR_No,
   MR_OK
};

var Color colTextMessage;
var MenuUIActionButtonWindow btnYes;
var MenuUIActionButtonWindow btnNo;
var MenuUIActionButtonWindow btnOK;
var MenuUIHeaderWindow winText;
var int  mbMode;
var bool bDeferredKeyPress;
var bool bKeyPressed;
var Window winNotify;
var int textBorderX;
var int textBorderY;
var int numButtons;
var localized string btnLabelYes;
var localized string btnLabelNo;
var localized string btnLabelOK;
var localized string btnLabelCancel;

event InitWindow()
{
   Super.InitWindow();
   // Don't show if match has ended
   if (( DeusExMPGame(Player.DXGame) != None ) && DeusExMPGame(Player.DXGame).bClientNewMap )
      return;
   // Force the title bar to be a certain width;
   winTitle.minTitleWidth = 250;

   CreateTextWindow();
   SetTitle("AntiTK mutator");
   SetMode(0);
   SetNotifyWindow(Self);
}

function CreateTextWindow()
{
   winText = CreateMenuHeader(21, 13, "", winClient);
   winText.SetTextAlignments(HALIGN_Center, VALIGN_Center);
   winText.SetFont(Font'FontMenuHeaders_DS');
   winText.SetWindowAlignments(HALIGN_Full, VALIGN_Full, textBorderX, textBorderY);
}

function SetMessageText( String msgText )
{
   winText.SetText(msgText);

   AskParentForReconfigure();
}

function SetDeferredKeyPress(bool bNewDeferredKeyPress)
{
   bDeferredKeyPress = bNewDeferredKeyPress;
}

function SetMode( int newMode )
{
   mbMode = newMode;

   switch( mbMode )
   {
      case 0:         // MB_YesNo:
         btnNo  = winButtonBar.AddButton(btnLabelNo, HALIGN_Right);
         btnYes = winButtonBar.AddButton(btnLabelYes, HALIGN_Right);
         numButtons = 2;
         SetFocusWindow(btnYes);
         break;

      case 1:         // MB_OK:
         btnOK = winButtonBar.AddButton(btnLabelOK, HALIGN_Right);
         numButtons = 1;
         SetFocusWindow(btnOK);
         break;
   }

   if (winShadow != None)
      MenuUIMessageBoxShadowWindow(winShadow).SetButtonCount(numButtons);
}

function int GetNumButtons()
{
   return numButtons;
}

function SetNotifyWindow( Window newWinNotify )
{
   winNotify = newWinNotify;
}

function bool ButtonActivated( Window buttonPressed )
{
   local bool bHandled;

   bHandled = True;

   Super.ButtonActivated(buttonPressed);

   switch( buttonPressed )
   {
      case btnYes:
         if ((bDeferredKeyPress) && (IsKeyDown(IK_Enter) || IsKeyDown(IK_Space) || IsKeyDown(IK_Y)))
            bKeyPressed = True;
         else
            PostResult(0);  // MR_Yes;

         bHandled = True;
         break;

      case btnNo:
         PostResult(1);
         break;

      case btnOK:
         if ((bDeferredKeyPress) && (IsKeyDown(IK_Enter) || IsKeyDown(IK_Space) || IsKeyDown(IK_Y)))
            bKeyPressed = True;
         else
            PostResult(0);

         bHandled = True;
         break;

      default:
         bHandled = False;
         break;
   }

   return bHandled;
}

event bool MouseButtonReleased(float pointX, float pointY, EInputKey button, int numClicks)
{
   return True;
}

event bool VirtualKeyPressed(EInputKey key, bool bRepeat)
{
   local bool bHandled;

   switch( key )
   {   
      case IK_Escape:
         switch( mbMode )
         {
            case 0:      // MB_YesNo:
               PostResult(1);
               break;
            case 1:      // MB_OK:
               PostResult(0);
               break;
         }
         bHandled = True;
         break;

      case IK_Enter:   
      case IK_Space:
         if (bDeferredKeyPress)
            bKeyPressed = True;
         else
            PostResult(0);

         bHandled = True;
         break;

      case IK_Y:
         if ( mbMode == 0  /*MB_YesNo*/ )
         {
            if (bDeferredKeyPress)
               bKeyPressed = True;
            else
               PostResult(0);

            bHandled = True;
         }
         break;

      case IK_N:
         if ( mbMode == 0  /*MB_YesNo*/ )
         {
            PostResult(1);
            bHandled = True;
         }
         break;
   }

   return bHandled;
}

event bool RawKeyPressed(EInputKey key, EInputState iState, bool bRepeat)
{
   if (((key == IK_Enter) || (key == IK_Space) || (key == IK_Y)) &&
      ((iState == IST_Release) && (bKeyPressed)))
   {
      PostResult(0);
      return True;
   }
   else
   {
      return false;
   }
}

function PostResult( int buttonNumber )
{
   local DeusExBaseWindow DEBW;
   Player.ConsoleCommand("mutate antitk."$buttonnumber);
   root.PopWindow();
   root.ClearWindowStack();
    Player.Fire();
}

defaultproperties
{
    textBorderX=20
    textBorderY=14
    btnLabelYes="|&Yes"
    btnLabelNo="|&No"
    btnLabelOK="|&OK"
    btnLabelCancel="|&Cancel"
    ClientWidth=280
    ClientHeight=85
    clientTextures(0)=Texture'DeusExUI.UserInterface.MenuMessageBoxBackground_1'
    clientTextures(1)=Texture'DeusExUI.UserInterface.MenuMessageBoxBackground_2'
    textureRows=1
    textureCols=2
    bActionButtonBarActive=True
    bUsesHelpWindow=False
    winShadowClass=Class'MenuUIMessageBoxShadowWindow'
}


I wasn't sure how to pass the results of a window to the mutator itself, so I just made the window (AskingMBW) run a "mutate ..." command which is handled in mutator code (so, antitk.0 is called when "no" button is pressed). The player, of course, doesn't know that. Ugly way, though.
User avatar
Dae
Alpha
 
Posts: 12086
Joined: Sat Sep 06, 03 4:40 pm

Postby ~ô¿ô~Nobody~ » Sat Mar 03, 07 2:15 pm

Changing from a pure keybased tool to a window based one, is a BIG step.
You need to know about replication, the bunch of native functions and structures, to make your window system.
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Ayleth » Sat Mar 03, 07 7:59 pm

ok thanks guys... i may need help later on, judging on what Nobody says....
kk first off..... if you guys could post more examples of code, thatd be great... also... im gunna need a scrolling list to have a list of players, and just click twice to load that player. that i fear will be hard.
Does anyone wanna join me on this project? i will need help.
¨‘°ºMåsåmµñ£º°‘¨
˙•●●ĊђασsΪηcǻяйαѓε●●•˙
jason.unger@gmail.com
User avatar
Ayleth
Regular
 
Posts: 313
Joined: Sun Jul 09, 06 7:27 pm
Location: 6 feet under. and trying to get out!

Postby Dae » Sat Mar 03, 07 8:34 pm

You need a code of Allan's TempBan mutator. It has a nice window
User avatar
Dae
Alpha
 
Posts: 12086
Joined: Sat Sep 06, 03 4:40 pm

Postby Ayleth » Sat Mar 03, 07 8:50 pm

i could use that....

Edit: Dae, may i directly copy your externalactor and modify it for what i will do? I assume all it does is pass tthe text to the window, and pop up the window?

Edit:edit: look at http://www.dxalpha.com/forum/viewtopic. ... 377#169377 for public topic and agenda.
¨‘°ºMåsåmµñ£º°‘¨
˙•●●ĊђασsΪηcǻяйαѓε●●•˙
jason.unger@gmail.com
User avatar
Ayleth
Regular
 
Posts: 313
Joined: Sun Jul 09, 06 7:27 pm
Location: 6 feet under. and trying to get out!

oh...

Postby Andrievskaya Veronika » Thu Mar 29, 07 4:03 am

Please help me. I want to get some information about chosen map.

For example i selected map "MyMap", and then i clicking button "Map Details"

I already created window, where such information should be displayed, but i don't have any ideas, how to get info from chosen map....

I want to use DeusExLevelInfo to get information from it.
User avatar
Andrievskaya Veronika
Poster
 
Posts: 164
Joined: Sat Sep 02, 06 7:35 am
Location: Database read error

Postby Dae » Thu Mar 29, 07 6:36 am

So you want to obtain the information about the map without loading it?
User avatar
Dae
Alpha
 
Posts: 12086
Joined: Sat Sep 06, 03 4:40 pm

Postby Andrievskaya Veronika » Thu Mar 29, 07 8:18 am

Yes, sure. I think this is possible.
User avatar
Andrievskaya Veronika
Poster
 
Posts: 164
Joined: Sat Sep 02, 06 7:35 am
Location: Database read error


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 38 guests