Skip to content

Commit

Permalink
Merge branch 'main' into fix/multiple-mod-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alystrasz authored Nov 23, 2024
2 parents 1b58941 + 1c48574 commit c5bba85
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/nativefuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@
"returnTypeString": "void",
"argTypes": "string name, string version"
},
{
"name": "NSCancelModDownload",
"helpText": "prevents installation of the mod currently being installed",
"returnTypeString": "void",
"argTypes": ""
},
{
"name": "NSGetModInstallState",
"helpText": "get status of the mod currently being installed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a
// In-game chat
"HUD_CHAT_WHISPER_PREFIX" "[WHISPER]"
"HUD_CHAT_SERVER_PREFIX" "[SERVER]"

// Team Switching
"TEAMSWITCH_GAMEMODE" "Gamemode does not allow Team Switching"
"TEAMSWITCH_BUFFER" "Team Switching is on Cooldown"
"TEAMSWITCH_GAMEPLAY" "Team change not allowed outside playing phase"
"TEAMSWITCH_DISABLED" "Current gamemode doesn't support team change"

"NO_GAMESERVER_RESPONSE" "Couldn't reach game server"
"BAD_GAMESERVER_RESPONSE" "Game server gave an invalid response"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
"PROGRESSION_ANNOUNCEMENT_BODY" "^CCCC0000進行システムが開放されました!^\n\nNorthstarはバニラの進行システム、つまり武器、スキン、タイタン等をレベルアップやチャレンジ達成で解除する機能をサポートしています。\n\nこの進行システムは、ロビー画面下のボタンから有効にできます。\n\nこの設定はいつでも変更可能です。"
"MOD_NOT_VERIFIED" "(Modが検証されていないため、自動ダウンロードできませんでした)"
"WRONG_MOD_VERSION" "サーバーはMod\"%s1\"v%s2 を要求していますが、あなたのModバージョンは%s3です"
"MODE_MENU_PVPVE" "PvPvE"

// Translation done by Zetryox and CYakigasi
}
Expand Down
21 changes: 21 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ void function InitInGameMPMenu()
var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" )
var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" )
Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate )
var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" )
Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch )
thread UpdateTeamSwitchButton_Threaded( teamChangeButton )
#if DEV
var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" )
Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) )
Expand Down Expand Up @@ -700,3 +703,21 @@ void function SetTitanSelectButtonVisibleState( bool state )
Hud_Hide( file.titanSelectButton )
}
}

void function UpdateTeamSwitchButton_Threaded( var button )
{
while ( true )
{
Hud_SetLocked( button, !GetConVarBool( "ns_allow_team_change" ) )
wait 0.5
}
}

void function OnRequestTeamSwitch( var button )
{
if ( !Hud_IsLocked( button ) )
{
ClientCommand( "changeteam" )
CloseAllMenus()
}
}
19 changes: 19 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ns_moddownload.nut
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ global enum eModInstallStatus
CHECKSUMING,
EXTRACTING,
DONE,
ABORTED,
FAILED,
FAILED_READING_ARCHIVE,
FAILED_WRITING_TO_DISK,
Expand Down Expand Up @@ -57,6 +58,11 @@ bool function DownloadMod( RequiredModInfo mod )
dialogData.message = Localize( "#DOWNLOADING_MOD_TEXT", mod.name, mod.version )
dialogData.showSpinner = true;

// Prevent download button
AddDialogButton( dialogData, "#CANCEL", void function() {
NSCancelModDownload()
})

// Prevent user from closing dialog
dialogData.forceChoice = true;
OpenDialog( dialogData )
Expand All @@ -77,6 +83,13 @@ bool function DownloadMod( RequiredModInfo mod )
WaitFrame()
}

// If download was aborted, don't close UI since it was closed by clicking cancel button
if ( state.status == eModInstallStatus.ABORTED )
{
print("Mod download was cancelled by the user.")
return false;
}

printt( "Mod status:", state.status )

// Close loading dialog
Expand Down Expand Up @@ -114,6 +127,12 @@ void function DisplayModDownloadErrorDialog( string modName )
{
ModInstallState state = NSGetModInstallState()

// If user cancelled download, no need to display an error message
if ( state.status == eModInstallStatus.ABORTED )
{
return
}

DialogData dialogData
dialogData.header = Localize( "#FAILED_DOWNLOADING", modName )
dialogData.image = $"ui/menu/common/dialog_error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void function GamemodeHidden_Init()
SetLoadoutGracePeriodEnabled( false ) // prevent modifying loadouts with grace period
SetWeaponDropsEnabled( false )
SetRespawnsEnabled( false )
SetGamemodeAllowsTeamSwitch( false )
Riff_ForceTitanAvailability( eTitanAvailability.Never )
Riff_ForceBoostAvailability( eBoostAvailability.Disabled )
Riff_ForceSetEliminationMode( eEliminationMode.Pilots )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void function GamemodeInfection_Init()
SetSpawnpointGamemodeOverride( FFA )
SetLoadoutGracePeriodEnabled( false ) // prevent modifying loadouts with grace period
SetWeaponDropsEnabled( false )
SetGamemodeAllowsTeamSwitch( false )
SetShouldUseRoundWinningKillReplay( true )
Riff_ForceTitanAvailability( eTitanAvailability.Never )
Riff_ForceBoostAvailability( eBoostAvailability.Disabled )
Expand Down
4 changes: 3 additions & 1 deletion Northstar.Custom/mod/scripts/vscripts/sh_message_utils.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,14 @@ void function NSSendPopUpMessageToPlayer( entity player, string text )
ServerToClientStringCommand( player, "ServerHUDMessageShow " + eMessageType.POPUP )
}

void function NSSendAnnouncementMessageToPlayer( entity player, string title, string description, vector color, int priority, int style )
void function NSSendAnnouncementMessageToPlayer( entity player, string title, string description, vector color, int priority, int style, string image = "" )
{
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.TITLE + " " + title )
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.DESC + " " + description )
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.COLOR + " " + color.x + " " + color.y + " " + color.z )
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.PRIORITY + " " + priority )
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.STYLE + " " + style )
ServerToClientStringCommand( player, "ServerHUDMessagePut " + eDataType.ASSET + " " + image )

ServerToClientStringCommand( player, "ServerHUDMessageShow " + eMessageType.ANNOUNCEMENT )
}
Expand Down Expand Up @@ -453,6 +454,7 @@ void function AnnouncementMessageHandler_Threaded()
Announcement_SetPriority( announcement, client.announcementQueue[0].priority )
Announcement_SetSoundAlias( announcement, SFX_HUD_ANNOUNCE_QUICK )
Announcement_SetStyle( announcement, client.announcementQueue[0].style )
Announcement_SetIcon( announcement, StringToAsset( strip( client.announcementQueue[0].image ) ) )
AnnouncementFromClass( GetLocalViewPlayer(), announcement )

wait 5
Expand Down
5 changes: 5 additions & 0 deletions Northstar.CustomServers/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"Name": "ns_progression_enabled",
"DefaultValue": "0",
"Flags": "ARCHIVE_PLAYERPROFILE"
},
{
"Name": "ns_allow_team_change",
"DefaultValue": "1",
"Flags": "REPLICATED"
}
],
"Scripts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ global function TrackTitanDamageInPlayerGameStat
global function ShouldEntTakeDamage_SPMP
global function GetTitanBuildTime
global function TitanPlayerHotDropsIntoLevel
global function SetGamemodeAllowsTeamSwitch

global function SetRecalculateRespawnAsTitanStartPointCallback

Expand All @@ -30,10 +31,13 @@ struct {
array<entity> specCams

entity functionref( entity player, entity basePoint ) recalculateRespawnAsTitanStartPointCallback
table<entity, float> playerChangeTeamTimeBuffer
bool gamemodeTeamSwitchEnabled = true
} file

void function BaseGametype_Init_MPSP()
{
AddClientCommandCallback( "changeteam", ClientCommandCallbackChangeTeam )
AddSpawnCallback( "info_intermission", SetIntermissionCamera )

AddPostDamageCallback( "player", AddToTitanDamageStat )
Expand Down Expand Up @@ -630,6 +634,51 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref
file.recalculateRespawnAsTitanStartPointCallback = callbackFunc
}

void function SetGamemodeAllowsTeamSwitch( bool enabled )
{
file.gamemodeTeamSwitchEnabled = enabled
}

bool function ClientCommandCallbackChangeTeam( entity player, array<string> args )
{
if ( !GetConVarBool( "ns_allow_team_change" ) || IsPrivateMatchSpectator( player ) )
return true

if ( !file.gamemodeTeamSwitchEnabled )
{
SendHudMessage( player, "#TEAMSWITCH_GAMEMODE", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return true
}

if ( !( player in file.playerChangeTeamTimeBuffer ) )
{
file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5.0
}
else
{
if ( file.playerChangeTeamTimeBuffer[ player ] > Time() )
{
SendHudMessage( player, "#TEAMSWITCH_BUFFER", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return true
}
}

if ( player in file.playerChangeTeamTimeBuffer && file.playerChangeTeamTimeBuffer[ player ] < Time() )
file.playerChangeTeamTimeBuffer[ player ] = Time() + 5.0

if ( !GamePlaying() )
{
SendHudMessage( player, "#TEAMSWITCH_GAMEPLAY", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return true
}
if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() )
SetTeam( player, GetOtherTeam( player.GetTeam() ) )
else
SendHudMessage( player, "#TEAMSWITCH_DISABLED", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )

return true
}

// stuff to change later

bool function ShouldEntTakeDamage_SPMP( entity ent, var damageInfo )
Expand Down

0 comments on commit c5bba85

Please sign in to comment.