Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

DeusEx.HUDObjectSlot


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
//=============================================================================
// HUDObjectSlot
//=============================================================================
class HUDObjectSlot expands ToggleWindow;

var DeusExPlayer player;

var int         objectNum;
var Inventory   item;
var Color       colObjectNum;
var Color       colObjectDesc;
var Color       colOutline;
var Color       fillColor;
var Color       colDropGood;
var Color       colDropBad;
var Color       colNone;
var Color       colSelected;
var Color       colSelectionBorder;
var int         slotFillWidth;
var int         slotFillHeight;
var int         borderWidth;
var int         borderHeight;

// Stuff to optimize DrawWindow()
var String      itemText;

// Drag/Drop Stuff
var PersonaScreenInventory winInv;      // Pointer back to the inventory window
var Int  clickX;
var Int  clickY;
var bool bDragStart;
var bool bDimIcon;  
var bool bAllowDragging;
var bool bDragging;                 // Set to True when we're dragging

enum FillModes
{
    FM_Selected,
    FM_DropGood,
    FM_DropBad,
    FM_None
};

var FillModes fillMode;

// Variables used to draw belt
var Texture     slotTextures;
var int         slotIconX;
var int         slotIconY;
var int         slotNumberX;
var int         slotNumberY;

// Used by DrawWindow()
var int itemTextPosY;

// Defaults
var EDrawStyle backgroundDrawStyle;
var Texture texBackground;
var Texture mpBorderTex; //For drawing borders between item slot sections in mp
var Color colBackground;

var Texture texBorders[9];

var localized String RoundLabel;
var localized String RoundsLabel;
var localized String CountLabel;

// ----------------------------------------------------------------------
// InitWindow()
// ----------------------------------------------------------------------

event InitWindow()
{
    Super.InitWindow();

    objectNum   = -1;
    item        = None;

    SetSelectability(false);

    SetSize(51, 54);
    SetFont(Font'FontTiny');

    // Get a pointer to the player
    player = DeusExPlayer(GetRootWindow().parentPawn);

    // Position where we'll be drawing the item-dependent text
    itemTextPosY = slotFillHeight - 8 + slotIconY;

    StyleChanged();
}

// ----------------------------------------------------------------------
// ToggleChanged()
// ----------------------------------------------------------------------

event bool ToggleChanged(Window button, bool bNewToggle)
{
    if ((item == None) && (bNewToggle))
    {
        SetToggle(False);
        return True;
    }
    else
    {
        return False;
    }
}

// ----------------------------------------------------------------------
// SetObjectNumber()
// ----------------------------------------------------------------------

function SetObjectNumber(int newNumber)
{
    objectNum = newNumber;
}

// ----------------------------------------------------------------------
// SetItem()
// ----------------------------------------------------------------------

function SetItem(Inventory newItem)
{
    item = newItem;
    if ( newItem != None )
    {
        newItem.bInObjectBelt = True;
        newItem.beltPos       = objectNum;
    }
    else
    {
        HighlightSelect(False);
        SetToggle(False);
    }

    // Update the text that will be displayed above the icon (if any)
    UpdateItemText();
}

// ----------------------------------------------------------------------
// UpdateItemText()
// ----------------------------------------------------------------------

function UpdateItemText()
{
    local DeusExWeapon weapon;

    itemText = "";

    if (item != None)
    {
        if (item.IsA('DeusExWeapon'))
        {
            // If this is a weapon, show the number of remaining rounds 
            weapon = DeusExWeapon(item);

            // Ammo loaded
            if ((weapon.AmmoName != class'AmmoNone') && (!weapon.bHandToHand) && (weapon.ReloadCount != 0) && (weapon.AmmoType != None))
                itemText = weapon.AmmoType.beltDescription;

            // If this is a grenade
            if (weapon.IsA('WeaponNanoVirusGrenade') || 
                weapon.IsA('WeaponGasGrenade') || 
                weapon.IsA('WeaponEMPGrenade') ||
                weapon.IsA('WeaponLAM'))
            {
                if (weapon.AmmoType.AmmoAmount > 1)
                    itemText = CountLabel @ weapon.AmmoType.AmmoAmount;
            }

        }
        else if (item.IsA('DeusExPickup') && (!item.IsA('NanoKeyRing')))
        {
            // If the object is a SkilledTool (but not the NanoKeyRing) then show the 
            // number of uses
            if (DeusExPickup(item).NumCopies > 1)
                itemText = DeusExPickup(item).CountLabel @ String(DeusExPickup(item).NumCopies);
        }
    }
}

// ----------------------------------------------------------------------
// GetItem()
// ----------------------------------------------------------------------

function Inventory GetItem()
{
    return (item);
}

// ----------------------------------------------------------------------
// DrawWindow()
// ----------------------------------------------------------------------

event DrawWindow(GC gc)
{
    // First draw the background
   DrawHUDBackground(gc);

    // Now fill the area under the icon, which can be different 
    // colors based on the state of the item.
    //
    // Don't waste time drawing the fill if the fillMode is set
    // to None

    if (fillMode != FM_None)
    {
        SetFillColor();
        gc.SetStyle(DSTY_Translucent);
        gc.SetTileColor(fillColor);
        gc.DrawPattern( 
            slotIconX, slotIconY, 
            slotFillWidth, slotFillHeight, 
            0, 0, Texture'Solid' );
    }

    // Don't draw any of this if we're dragging
    if ((item != None) && (item.Icon != None) && (!bDragging))
    {
        // Draw the icon
      DrawHUDIcon(gc);

        // Text defaults
        gc.SetAlignments(HALIGN_Center, VALIGN_Center);
        gc.EnableWordWrap(false);
        gc.SetTextColor(colObjectNum);

        // Draw the item description at the bottom
        gc.DrawText(1, 42, 42, 7, item.BeltDescription);

        // If there's any additional text (say, for an ammo or weapon), draw it
        if (itemText != "")
            gc.DrawText(slotIconX, itemTextPosY, slotFillWidth, 8, itemText);

        // Draw selection border
        if (bButtonPressed)
        {
            gc.SetTileColor(colSelectionBorder);
            gc.SetStyle(DSTY_Masked);
            gc.DrawBorders(slotIconX - 1, slotIconY - 1, borderWidth, borderHeight, 0, 0, 0, 0, texBorders);
        }
    }
   else if ((item == None) && (player != None) && (player.Level.NetMode != NM_Standalone) && (player.bBeltIsMPInventory))
   {
        // Text defaults
        gc.SetAlignments(HALIGN_Center, VALIGN_Center);
        gc.EnableWordWrap(false);
        gc.SetTextColor(colObjectNum);

        if ((objectNum >=1) && (objectNum <=3))
      {
         gc.DrawText(1, 42, 42, 7, "WEAPONS");
      }
      else if ((objectNum >=4) && (objectNum <=6))
      {
         gc.DrawText(1, 42, 42, 7, "GRENADES");
      }
      else if ( ((objectNum >=7) && (objectNum <=9)) || (objectNum == 0) )
      {
         gc.DrawText(1, 42, 42, 7, "TOOLS");
      }
   }
    
    // Draw the Object Slot Number in upper-right corner
    gc.SetAlignments(HALIGN_Right, VALIGN_Center);
    gc.SetTextColor(colObjectNum);
    gc.DrawText(slotNumberX - 1, slotNumberY, 6, 7, objectNum);
}

function DrawHUDIcon(GC gc)
{
        gc.SetStyle(DSTY_Masked);
        gc.SetTileColorRGB(255, 255, 255);
        gc.DrawTexture(slotIconX, slotIconY, slotFillWidth, slotFillHeight, 0, 0, item.Icon);
}

function DrawHUDBackground(GC gc)
{
    local Color newBackground;
            
    gc.SetStyle(backgroundDrawStyle);
    if (( player != None ) && (player.Level.NetMode != NM_Standalone) && (player.bBuySkills))
    {
        newBackground.r = colBackground.r / 2;
        newBackground.g = colBackground.g / 2;
        newBackground.b = colBackground.b / 2;
        gc.SetTileColor(newBackground);
    }
    else
        gc.SetTileColor(colBackground);

   // DEUS_EX AMSD Warning.  This background delineates specific item locations on the belt, which
   // are usually only known to the items themselves.
   if ( (player != None) && (Player.Level.Netmode != NM_Standalone) && (Player.bBeltIsMPInventory) && ((objectNum == 3) || (objectNum == 6)) )
   {
      gc.DrawTexture(0, 0, width, height, 0, 0, mpBorderTex);
   }
   else 
      gc.DrawTexture(0, 0, width, height, 0, 0, texBackground);
}

// ----------------------------------------------------------------------
// SetDropFill()
// ----------------------------------------------------------------------

function SetDropFill(bool bGoodDrop)
{
    if (bGoodDrop)
        fillMode = FM_DropGood;
    else
        fillMode = FM_DropBad;
}

// ----------------------------------------------------------------------
// AllowDragging()
// ----------------------------------------------------------------------

function AllowDragging(bool bNewAllowDragging)
{
    bAllowDragging = bNewAllowDragging;
}

// ----------------------------------------------------------------------
// ResetFill()
// ----------------------------------------------------------------------

function ResetFill()
{
    fillMode = FM_None;
}

// ----------------------------------------------------------------------
// HighlightSelect()
// ----------------------------------------------------------------------

function HighlightSelect(bool bHighlight)
{
    if (bHighlight) 
        fillMode = FM_Selected;
    else
        fillMode = FM_None;
}

// ----------------------------------------------------------------------
// SetFillColor()
// ----------------------------------------------------------------------

function SetFillColor()
{
    switch(fillMode)
    {
        case FM_Selected:
            fillColor = colSelected;
            break;
        case FM_DropBad:
            fillColor = colDropBad;
            break;
        case FM_DropGood:
            fillColor = colDropGood;
            break;
        case FM_None:
            fillColor = colNone;
            break;
    }
}

// ----------------------------------------------------------------------
// MouseButtonPressed()
//
// If the user presses the mouse button, initiate drag mode, 
// but only if this button has an inventory item associated
// with it.
// ----------------------------------------------------------------------

event bool MouseButtonPressed(float pointX, float pointY, EInputKey button,
                              int numClicks)
{
    local Bool bResult;

    bResult = False;

    if ((item != None) && (button == IK_LeftMouse))
    {
        bDragStart = True;
        clickX = pointX;
        clickY = pointY;
        bResult = True;
    }
    return bResult;
}

// ----------------------------------------------------------------------
// MouseButtonReleased()
//
// If we were in drag mode, then release the mouse button.
// If the player is over a new (and valid) inventory location or 
// object belt location, drop the item here.
// ----------------------------------------------------------------------

event bool MouseButtonReleased(float pointX, float pointY, EInputKey button,
                               int numClicks)
{
    if (button == IK_LeftMouse)
    {
        FinishButtonDrag();
        return True;
    }
    else
    {
        return false;  // don't handle
    }
}

// ----------------------------------------------------------------------
// MouseMoved()
// ----------------------------------------------------------------------

event MouseMoved(float newX, float newY)
{
    local Float invX;
    local Float invY;

    if (bAllowDragging)
    {
        if (bDragStart)
        {
            // Only start a drag even if the cursor has moved more than, say,
            // two pixels.  This prevents problems if the user just wants to 
            // click on an item to select it but is a little sloppy.  :)
            if (( Abs(newX - clickX) > 2 ) || ( Abs(newY- clickY) > 2 ))
            {
                StartButtonDrag();
                SetCursorPos(
                    slotIconX + slotFillWidth/2, 
                    slotIconY + slotFillHeight/2);
            }
        }

        if (bDragging)
        {
            // Call the InventoryWindow::MouseMoved function, with translated
            // coordinates.
            ConvertCoordinates(Self, newX, newY, winInv, invX, invY);
            winInv.UpdateDragMouse(invX, invY);
        }
    }
}

// ----------------------------------------------------------------------
// CursorRequested()
//
// If we're dragging an inventory item, then set the cursor to that 
// icon.  Otherwise return None, meaning use the default cursor icon.
// ----------------------------------------------------------------------

event texture CursorRequested(window win, float pointX, float pointY,
                              out float hotX, out float hotY, out color newColor, 
                              out Texture shadowTexture)
{
    shadowTexture = None;

    hotX = slotFillWidth / 2;
    hotY = slotFillHeight / 2;

    if ((item != None) && (bDragging))
    {
        if (bDimIcon)
        {
            newColor.R = 64;
            newColor.G = 64;
            newColor.B = 64;
        }

        return item.Icon;
    }
    else
    {
        return None;
    }
}

// ----------------------------------------------------------------------
// StartButtonDrag()
// ----------------------------------------------------------------------

function StartButtonDrag()
{
    bDragStart = False;
    bDragging  = True;

    winInv.StartButtonDrag(Self);
}

// ----------------------------------------------------------------------
// FinishButtonDrag()
// ----------------------------------------------------------------------

function FinishButtonDrag()
{
    winInv.FinishButtonDrag();
    
    bDragStart = False;
    bDragging  = False;
}

// ----------------------------------------------------------------------
// AssignWinInv()
// ----------------------------------------------------------------------

function AssignWinInv(PersonaScreenInventory newWinInventory)
{
    winInv = newWinInventory;
}

// ----------------------------------------------------------------------
// GetIconPos()
//
// Returns the location where the icon will be drawn
// ----------------------------------------------------------------------

function GetIconPos(out int iconPosX, out int iconPosY)
{
    iconPosX = slotIconX;
    iconPosY = slotIconY;
}

// ----------------------------------------------------------------------
// StyleChanged()
// ----------------------------------------------------------------------

event StyleChanged()
{
    local ColorTheme theme;

    theme = player.ThemeManager.GetCurrentHUDColorTheme();

    colBackground = theme.GetColorFromName('HUDColor_Background');
    colObjectNum  = theme.GetColorFromName('HUDColor_NormalText');

    colSelected.r = Int(Float(colBackground.r) * 0.50);
    colSelected.g = Int(Float(colBackground.g) * 0.50);
    colSelected.b = Int(Float(colBackground.b) * 0.50);

    if (player.GetHUDBackgroundTranslucency())
        backgroundDrawStyle = DSTY_Translucent;
    else
        backgroundDrawStyle = DSTY_Masked;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
     colObjectNum=(G=170,B=255)
     colDropGood=(R=32,G=128,B=32)
     colDropBad=(R=128,G=32,B=32)
     colSelected=(R=60,G=60,B=60)
     colSelectionBorder=(R=255,G=255,B=255)
     slotFillWidth=42
     slotFillHeight=37
     borderWidth=44
     borderHeight=50
     bAllowDragging=True
     fillMode=FM_None
     slotIconX=1
     slotIconY=3
     slotNumberX=38
     slotNumberY=3
     texBackground=Texture'DeusExUI.UserInterface.HUDObjectBeltBackground_Cell'
     mpBorderTex=Texture'DeusExUI.UserInterface.HUDObjectBeltBackground_Divider'
     texBorders(0)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_TL'
     texBorders(1)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_TR'
     texBorders(2)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_BL'
     texBorders(3)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_BR'
     texBorders(4)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_Left'
     texBorders(5)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_Right'
     texBorders(6)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_Top'
     texBorders(7)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_Bottom'
     texBorders(8)=Texture'DeusExUI.UserInterface.PersonaItemHighlight_Center'
     RoundLabel="%d Rd"
     RoundsLabel="%d Rds"
     CountLabel="COUNT:"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:50.000 - Creation time: Mon 8/11/2021 16:31:27.335 - Created with UnCodeX