Partial implementation of Autocannon.

Fix mouse input in menus (among other things).
This commit is contained in:
Marisa the Magician 2019-09-20 16:03:06 +02:00
commit f6ed8c5281
5 changed files with 195 additions and 12 deletions

View file

@ -117,8 +117,8 @@ OptionMenu "UnrealCreditsMenu"
ListMenu "MainMenu"
{
Class "UnrealListMenu"
LineSpacing 40
UnrealBg " "
Position 0, 0
UnrealTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu"
UnrealTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
@ -133,8 +133,8 @@ ListMenu "MainMenu"
ListMenu "MainMenuTextOnly"
{
Class "UnrealListMenu"
LineSpacing 40
UnrealBg " "
Position 0, 0
UnrealTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu"
UnrealTextItem "$MNU_OPTIONS", "o", "OptionsMenu"

View file

@ -12,3 +12,76 @@ Model "SMiniGun"
ROTATING
FrameIndex SMIP A 1 0
}
Model "SMiniGun"
{
Path "models"
Model 0 "SMinigun_d.3d"
Skin 0 "Minigun.png"
AngleOffset 180
Scale 0.1 -0.08 0.1
Offset 6 -18 -10
// Down
FrameIndex SMID A 0 1
FrameIndex SMID B 0 2
FrameIndex SMID C 0 3
FrameIndex SMID D 0 4
FrameIndex SMID E 0 5
FrameIndex SMID F 0 6
// Select
FrameIndex SMIS A 0 6
FrameIndex SMIS B 0 7
FrameIndex SMIS C 0 8
FrameIndex SMIS D 0 9
FrameIndex SMIS E 0 10
FrameIndex SMIS F 0 11
FrameIndex SMIS G 0 12
FrameIndex SMIS H 0 13
FrameIndex SMIS I 0 14
// Idle
FrameIndex SMII A 0 15
FrameIndex SMII B 0 16
FrameIndex SMII C 0 17
FrameIndex SMII D 0 18
FrameIndex SMII E 0 19
// Fire1
FrameIndex SMIF A 0 20
FrameIndex SMIF B 0 21
FrameIndex SMIF C 0 22
FrameIndex SMIF D 0 23
FrameIndex SMIF E 0 24
FrameIndex SMIF F 0 25
// Fire2
FrameIndex SMIF G 0 26
FrameIndex SMIF H 0 27
FrameIndex SMIF I 0 28
FrameIndex SMIF J 0 29
FrameIndex SMIF K 0 30
FrameIndex SMIF L 0 31
// Fire3
FrameIndex SMIF M 0 32
FrameIndex SMIF N 0 33
FrameIndex SMIF O 0 34
FrameIndex SMIF P 0 35
FrameIndex SMIF Q 0 36
FrameIndex SMIF R 0 37
// Fire4
FrameIndex SMIF S 0 38
FrameIndex SMIF T 0 39
FrameIndex SMIF U 0 40
FrameIndex SMIF V 0 41
FrameIndex SMIF W 0 42
FrameIndex SMIF X 0 43
// AltFire
FrameIndex SMIA A 0 44
FrameIndex SMIA B 0 45
FrameIndex SMIA C 0 46
FrameIndex SMIA D 0 47
FrameIndex SMIA E 0 48
FrameIndex SMIA F 0 49
FrameIndex SMIA G 0 50
FrameIndex SMIA H 0 51
FrameIndex SMIA I 0 52
FrameIndex SMIA J 0 53
}

View file

@ -292,6 +292,11 @@ big/reload bigmrelo
big/shell bigmshel
big/blast bigmhit
smini/select sminisel
smini/fire sminione
smini/altfire sminialt
smini/endfire sminiend
translator/event transa3
detector/start detact

View file

@ -69,6 +69,28 @@ Class SMiniGun : UnrealWeapon
Destroy();
}
}
action void A_SMiniFire( bool bAlt = false )
{
if ( bAlt ) invoker.special1 = 0;
else
{
State which = ResolveState("FireOne");
if ( invoker.special1 == 1 ) which = ResolveState("FireTwo");
else if ( invoker.special1 == 2 ) which = ResolveState("FireThree");
else if ( invoker.special1 == 3 ) which = ResolveState("FireFour");
player.SetPSprite(PSP_WEAPON,which);
invoker.special1 = (invoker.special1%4)+1;
}
A_PlaySound(bAlt?"smini/altfire":"smini/fire",CHAN_WEAPON);
// TODO everything
}
action void A_Cooldown()
{
// TODO steam effect
invoker.special2--;
if ( invoker.special2 <= 0 )
player.SetPSprite(PSP_WEAPON,ResolveState("Idle"));
}
Default
{
Tag "$T_SMINI";
@ -94,5 +116,66 @@ Class SMiniGun : UnrealWeapon
Stop;
SMIP B -1;
Stop;
Select:
SMIS A 1 A_Raise(int.max);
Wait;
Ready:
SMIS ABCDEFGHI 2 A_WeaponReady(WRF_NOFIRE);
Goto Idle;
Dummy:
TNT1 A 1
{
A_CheckReload();
A_WeaponReady();
}
Wait;
Idle:
SMII A 0 A_Overlay(-9999,"Dummy");
SMII ABCDE 20;
Goto Idle+1;
Fire:
SMIF A 0
{
A_Overlay(-9999,"Dummy");
A_SMiniFire(false);
}
FireOne:
SMIF ABCDEF 2;
SMII A 0 A_Refire("Fire");
Goto Release;
FireTwo:
SMIF GHIJKL 2;
SMII A 0 A_Refire("Fire");
Goto Release;
FireThree:
SMIF MNOPQR 2;
SMII A 0 A_Refire("Fire");
Goto Release;
FireFour:
SMIF STUVWX 2;
SMII A 0 A_Refire("Fire");
Goto Release;
AltFire:
SMIA A 0
{
A_Overlay(-9999,"Dummy");
A_SMiniFire(true);
}
SMIA ABCDEFGHIJ 3;
SMII A 0 A_Refire("AltFire");
Goto Release;
Release:
SMII A 0
{
A_PlaySound("smini/endfire",CHAN_ITEM);
invoker.special2 = 25;
}
SMII A 1 A_Cooldown();
Wait;
Deselect:
#### # 1 A_Overlay(-9999,"Null");
SMID ABCDEF 1;
SMID F 1 A_Lower(int.max);
Wait;
}
}

View file

@ -1,17 +1,16 @@
// draws unreal-style main menu
Class ListMenuItemUnrealBg : ListMenuItem
Class UnrealListMenu : ListMenu
{
TextureID tex[3];
void Init( ListMenuDescriptor desc, String dummy )
override void Init( Menu parent, ListMenuDescriptor desc )
{
Super.Init(0,0);
Super.Init(parent,desc);
tex[0] = TexMan.CheckForTexture("graphics/rmetal.png",TexMan.Type_Any);
tex[1] = TexMan.CheckForTexture("graphics/menubarr.png",TexMan.Type_Any);
tex[2] = TexMan.CheckForTexture("graphics/unlogo.png",TexMan.Type_Any);
}
override void Drawer( bool selected )
override void Drawer()
{
double StartX = 0.5*CleanWidth_1-128;
int num = (CleanHeight_1/512)+1;
@ -19,6 +18,30 @@ Class ListMenuItemUnrealBg : ListMenuItem
Screen.DrawTexture(tex[0],false,StartX*CleanXFac_1,512*CleanYFac_1*i,DTA_CleanNoMove_1,true);
Screen.DrawTexture(tex[1],false,StartX*CleanXFac_1,(CleanHeight_1-58)*CleanYFac_1,DTA_CleanNoMove_1,true,DTA_LegacyRenderStyle,STYLE_Add);
Screen.DrawTexture(tex[2],false,StartX*CleanXFac_1,(CleanHeight_1-52)*CleanYFac_1,DTA_CleanNoMove_1,true);
Super.Drawer();
}
override bool MouseEvent( int type, int x, int y )
{
int sel = -1;
if ( mFocusControl )
{
mFocusControl.MouseEvent(type,x,y);
return true;
}
else
{
for ( int i=0; i<mDesc.mItems.Size(); i++ )
{
if ( mDesc.mItems[i].CheckCoordinate(x,y) )
{
mDesc.mSelectedItem = i;
mDesc.mItems[i].MouseEvent(type,x,y);
return true;
}
}
}
mDesc.mSelectedItem = -1;
return true;
}
}
@ -67,14 +90,13 @@ Class ListMenuItemUnrealTextItem : ListMenuItemSelectable
override bool CheckCoordinate( int x, int y )
{
/*String str = StringTable.Localize(mText);
String str = StringTable.Localize(mText);
let fnt = (generic_ui||!mFont.CanPrint(str))?NewSmallFont:mFont;
int w = fnt.StringWidth(str);
int h = fnt.GetHeight();
double basex = floor(0.5*(CleanWidth_1-w));
double basey = floor(0.25*(CleanHeight_1-mSpacing*5));
return (mEnabled && (x >= basex) && (x < basex+w) && (y >= basey) && (y < basey+h));*/
return false; // since we can't change the main menu class, this won't work anyway
double basex = floor(0.5*(CleanWidth_1-w))+mXPos;
double basey = floor(0.25*(CleanHeight_1-mSpacing*5))+mYPos;
return (mEnabled && (x >= basex) && (x < basex+w) && (y >= basey) && (y < basey+h));
}
override void DrawSelector( double xofs, double yofs, TextureID tex )