2017-02-17 15:53:36 +00:00
|
|
|
|
|
|
|
class PlayerMenu : ListMenu native
|
|
|
|
{
|
|
|
|
native int mRotation;
|
2017-02-17 17:21:59 +00:00
|
|
|
native PlayerClass mPlayerClass;
|
2017-02-17 19:02:26 +00:00
|
|
|
native Array<int> PlayerColorSets;
|
2017-02-17 17:21:59 +00:00
|
|
|
|
2017-02-17 19:02:26 +00:00
|
|
|
// All write function for the player config are native to prevent abuse.
|
2017-02-17 17:21:59 +00:00
|
|
|
protected native void AutoaimChanged(float val);
|
2017-02-17 19:02:26 +00:00
|
|
|
protected native void TeamChanged(int val);
|
|
|
|
protected native void AlwaysRunChanged(int val);
|
|
|
|
protected native void GenderChanged(int val);
|
|
|
|
protected native void SwitchOnPickupChanged(int val);
|
2017-02-17 17:21:59 +00:00
|
|
|
protected native void ColorChanged(int red, int green, int blue);
|
2017-02-17 19:02:26 +00:00
|
|
|
protected native void ColorSetChanged(int red);
|
|
|
|
protected native void PlayerNameChanged(String name);
|
|
|
|
|
|
|
|
protected native void ClassChanged(ListMenuItem it);
|
|
|
|
protected native void SkinChanged (ListMenuItem li);
|
2017-02-17 17:21:59 +00:00
|
|
|
|
|
|
|
protected void UpdateTranslation()
|
|
|
|
{
|
|
|
|
Translation.SetPlayerTranslation(TRANSLATION_Players, MAXPLAYERS, consoleplayer, mPlayerClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void SendNewColor (int red, int green, int blue)
|
|
|
|
{
|
|
|
|
ColorChanged(red, green, blue);
|
|
|
|
UpdateTranslation();
|
|
|
|
}
|
2017-02-17 15:53:36 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2017-02-17 19:02:26 +00:00
|
|
|
override bool MenuEvent (int mkey, bool fromcontroller)
|
|
|
|
{
|
|
|
|
int v;
|
|
|
|
bool res;
|
|
|
|
String s;
|
|
|
|
if (mDesc.mSelectedItem >= 0)
|
|
|
|
{
|
|
|
|
let li = mDesc.mItems[mDesc.mSelectedItem];
|
|
|
|
if (li.MenuEvent(mkey, fromcontroller))
|
|
|
|
{
|
|
|
|
Name ctrl = li.GetAction();
|
|
|
|
switch(ctrl)
|
|
|
|
{
|
|
|
|
// item specific handling comes here
|
|
|
|
|
|
|
|
case 'Playerbox':
|
|
|
|
if (mkey == MKEY_Input)
|
|
|
|
{
|
|
|
|
[res, s] = li.GetString(0);
|
|
|
|
if (res) PlayerNameChanged(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Team':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res) TeamChanged(v);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Color':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
int mycolorset = -1;
|
|
|
|
|
|
|
|
if (v > 0) mycolorset = PlayerColorSets[v - 1];
|
|
|
|
|
|
|
|
let red = GetItem('Red');
|
|
|
|
let green = GetItem('Green');
|
|
|
|
let blue = GetItem('Blue');
|
|
|
|
|
|
|
|
// disable the sliders if a valid colorset is selected
|
|
|
|
if (red != NULL) red.Enable(mycolorset == -1);
|
|
|
|
if (green != NULL) green.Enable(mycolorset == -1);
|
|
|
|
if (blue != NULL) blue.Enable(mycolorset == -1);
|
|
|
|
|
|
|
|
ColorSetChanged(v - 1);
|
|
|
|
UpdateTranslation();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Red':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (v, colr.g, colr.b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Green':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (colr.r, v, colr.b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Blue':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (colr.r, colr.g, v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Class':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
ClassChanged(li);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Skin':
|
|
|
|
SkinChanged(li);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Gender':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
GenderChanged(v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Autoaim':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
AutoaimChanged(v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Switch':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
SwitchOnPickupChanged(v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'AlwaysRun':
|
|
|
|
[res, v] = li.GetValue(0);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
AlwaysRunChanged(v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Super.MenuEvent(mkey, fromcontroller);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2017-02-17 17:21:59 +00:00
|
|
|
override bool MouseEvent(int type, int x, int y)
|
2017-02-17 15:53:36 +00:00
|
|
|
{
|
2017-02-17 17:21:59 +00:00
|
|
|
let li = mFocusControl;
|
|
|
|
bool res = Super.MouseEvent(type, x, y);
|
|
|
|
if (li == NULL) li = mFocusControl;
|
|
|
|
if (li != NULL)
|
|
|
|
{
|
|
|
|
// Check if the colors have changed
|
|
|
|
Name ctrl = li.GetAction();
|
|
|
|
bool resv;
|
|
|
|
int v;
|
|
|
|
[resv, v]= li.GetValue(0);
|
|
|
|
switch(ctrl)
|
|
|
|
{
|
|
|
|
case 'Red':
|
|
|
|
if (resv)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (v, colr.g, colr.b);
|
|
|
|
}
|
|
|
|
break;
|
2017-02-17 15:53:36 +00:00
|
|
|
|
2017-02-17 17:21:59 +00:00
|
|
|
case 'Green':
|
|
|
|
if (resv)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (colr.r, v, colr.b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Blue':
|
|
|
|
if (resv)
|
|
|
|
{
|
|
|
|
Color colr = players[consoleplayer].GetColor();
|
|
|
|
SendNewColor (colr.r, colr.g, v);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Autoaim':
|
|
|
|
AutoaimChanged(v);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2017-02-17 15:53:36 +00:00
|
|
|
|
2017-02-17 17:21:59 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
override void Drawer ()
|
|
|
|
{
|
|
|
|
Super.Drawer();
|
2017-02-17 15:53:36 +00:00
|
|
|
String str = "PRESS " .. TEXTCOLOR_WHITE .. "SPACE";
|
|
|
|
screen.DrawText (SmallFont, Font.CR_GOLD, 320 - 32 - 32 - SmallFont.StringWidth (str)/2, 50 + 48 + 70, str, DTA_Clean, true);
|
|
|
|
str = mRotation ? "TO SEE FRONT" : "TO SEE BACK";
|
|
|
|
screen.DrawText (SmallFont, Font.CR_GOLD, 320 - 32 - 32 - SmallFont.StringWidth (str)/2, 50 + 48 + 70 + SmallFont.GetHeight (), str, DTA_Clean, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|