Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vote map preview #1678

Open
wants to merge 12 commits into
base: feature-italy
Choose a base branch
from
5 changes: 5 additions & 0 deletions DH_Engine/Classes/DHMapDatabase.uc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ static function string GetHumanReadableMapName(string MapName)
return Repl(Repl(Repl(MapName, "_", " "), ".rom", ""), "DH-", "");
}

static function string GetMapNameForCache(string MapName)
{
return Repl(MapName, ".rom", "");
}

defaultproperties
{
MapInfos(0)=(Name="DH-St_Marie_du_Mont_Advance",AlliedNation=NATION_USA,GameType=GAMETYPE_Advance,Size=SIZE_Medium)
Expand Down
1 change: 1 addition & 0 deletions DH_Engine/Classes/DarkestHourGame.uc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct ArtilleryResponse
// Overridden to make new clamp of MaxPlayers and force AccessControlType
event InitGame(string Options, out string Error)
{

super.InitGame(Options, Error);

if (bIgnore32PlayerLimit)
Expand Down
6 changes: 3 additions & 3 deletions DH_Interface/Classes/DHMapVoteCountMultiColumnList.uc
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ function string GetSortString(int i)

defaultproperties
{
ColumnHeadings(0)="Nominated Maps"
ColumnHeadings(1)="Vote Weight"
ColumnHeadings(2)="Map Size"
ColumnHeadings(0)="Nominated"
ColumnHeadings(1)="Votes"
ColumnHeadings(2)="Size"
ColumnHeadingHints(0)="The map's name."
ColumnHeadingHints(1)="The combined voting power of players for the map."
ColumnHeadingHints(2)="Recommended players for the map."
Expand Down
7 changes: 7 additions & 0 deletions DH_Interface/Classes/DHMapVoteCountMultiColumnListBox.uc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

class DHMapVoteCountMultiColumnListBox extends MapVoteCountMultiColumnListBox;

function InitBaseList(GUIListBase ListBase)
{
super.InitBaseList(ListBase);

ListBase.OnChange = OnChange;
}

defaultproperties
{
ContextMenu=none
Expand Down
10 changes: 5 additions & 5 deletions DH_Interface/Classes/DHMapVoteMultiColumnList.uc
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ function string GetSortString(int i)
defaultproperties
{
// Map Name | Allied Nation | Axis Nation | Game Type | Map Size
ColumnHeadings(0)="Map Name"
ColumnHeadings(1)="Allied Nation"
ColumnHeadings(2)="Axis Nation"
ColumnHeadings(3)="Game Type"
ColumnHeadings(4)="Map Size"
ColumnHeadings(0)="Name"
ColumnHeadings(1)="Allied"
ColumnHeadings(2)="Axis"
ColumnHeadings(3)="Type"
ColumnHeadings(4)="Size"

InitColumnPerc(0)=0.40
InitColumnPerc(1)=0.15
Expand Down
6 changes: 6 additions & 0 deletions DH_Interface/Classes/DHMapVoteMultiColumnListBox.uc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

class DHMapVoteMultiColumnListBox extends MapVoteMultiColumnListBox;

function InitBaseList(GUIListBase ListBase)
{
super.InitBaseList(ListBase);

ListBase.OnChange = OnChange;
}
function LoadList(VotingReplicationInfo LoadVRI)
{
local int i, g;
Expand Down
114 changes: 102 additions & 12 deletions DH_Interface/Classes/DHMapVotingPage.uc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ var localized string lmsgMapOutOfBounds;

var automated moEditBox ed_Filter;
var automated GUIButton b_FilterClear;
var automated GUILabel l_MapPreviewName;
var automated GUIImage i_MapPreviewImage;

var automated GUIScrollTextBox lb_MapPreviewDesc;

var CacheManager.MapRecord mapRecord;


function InternalOnOpen()
{
Expand All @@ -28,6 +35,43 @@ function bool AlignBK(Canvas C)
return false;
}

function UpdatePreview(GUIComponent Sender)
{
local int MapIndex;
local string MapName;
local string MapDesc;

if (Sender == lb_VoteCountListBox.List)
{
MapIndex = MapVoteCountMultiColumnList(lb_VoteCountListBox.List).GetSelectedMapIndex();
}
else
{
MapIndex = MapVoteMultiColumnList(lb_MapListBox.List).GetSelectedMapIndex();
}

if (MapIndex > -1)
{

MapName = class'DHMapDatabase'.static.GetMapNameForCache(MVRI.MapList[MapIndex].MapName);
mapRecord = class'CacheManager'.static.GetMapRecord(MapName); //DH-Armored_La_Fueille_Advance

l_MapPreviewName.Caption = class'DHMapDatabase'.static.GetHumanReadableMapName(MVRI.MapList[MapIndex].MapName);
i_MapPreviewImage.Image = Material(DynamicLoadObject(mapRecord.ScreenshotRef, class'Material'));
MapDesc = mapRecord.Description;

if (MapDesc != "")
{
lb_MapPreviewDesc.SetContent(MapDesc);
}
else
{
lb_MapPreviewDesc.SetContent("No description available.");

}
}
}

function SendVote(GUIComponent Sender)
{
local int MapIndex, GameConfigIndex;
Expand Down Expand Up @@ -71,7 +115,7 @@ function SendVote(GUIComponent Sender)

if (MVRI.MapList[MapIndex].bEnabled || PlayerOwner().PlayerReplicationInfo.bAdmin)
{
MVRI.SendMapVote(MapIndex,GameConfigIndex);
MVRI.SendMapVote(MapIndex, GameConfigIndex);
}
else
{
Expand All @@ -89,7 +133,7 @@ function SendVote(GUIComponent Sender)

if (MVRI.MapList[MapIndex].bEnabled || PlayerOwner().PlayerReplicationInfo.bAdmin)
{
MVRI.SendMapVote(MapIndex,GameConfigIndex);
MVRI.SendMapVote(MapIndex, GameConfigIndex);
}
else
{
Expand All @@ -116,6 +160,10 @@ function bool InternalOnClick(GUIComponent Sender)
OnFilterClear();
return true;
}
else if (Sender == lb_MapListBox)
{
UpdatePreview(Sender);
}
}

delegate OnFilterClear()
Expand All @@ -127,11 +175,10 @@ delegate OnFilterClear()
defaultproperties
{
lmsgMapOutOfBounds="Please vote for a map suitable for the current player count. You can still vote for this map on the full list."

lmsgMode(0)="Majority Wins"

Begin Object class=DHMapVoteMultiColumnListBox Name=MapListBox
WinWidth=0.96
WinWidth=0.5
WinHeight=0.50
WinLeft=0.02
WinTop=0.371020
Expand All @@ -140,28 +187,30 @@ defaultproperties
bScaleToParent=true
bBoundToParent=true
FontScale=FNS_Small
HeaderColumnPerc(0)=0.40 // Map Name
HeaderColumnPerc(1)=0.15 // Allied Country
HeaderColumnPerc(2)=0.15 // Axis Country
HeaderColumnPerc(0)=0.40 // Name
HeaderColumnPerc(1)=0.15 // Allies
HeaderColumnPerc(2)=0.15 // Axis
HeaderColumnPerc(3)=0.15 // Type
HeaderColumnPerc(4)=0.15 // Player Range
HeaderColumnPerc(4)=0.15 // Size
OnChange=UpdatePreview
End Object
lb_MapListBox=DHMapVoteMultiColumnListBox'DH_Interface.DHMapVotingPage.MapListBox'

Begin Object class=DHMapVoteCountMultiColumnListBox Name=VoteCountListBox
HeaderColumnPerc(0)=0.4 // Nominated Maps
HeaderColumnPerc(1)=0.3 // Votes
HeaderColumnPerc(2)=0.3 // Player Range
HeaderColumnPerc(2)=0.3 // Size
DefaultListClass="DH_Interface.DHMapVoteCountMultiColumnList"
bVisibleWhenEmpty=true
OnCreateComponent=VoteCountListBox.InternalOnCreateComponent
StyleName="ServerBrowserGrid"
WinTop=0.077369
WinLeft=0.02
WinWidth=0.96
WinWidth=0.5
WinHeight=0.26752
bBoundToParent=true
bScaleToParent=true
OnChange=UpdatePreview
OnRightClick=VoteCountListBox.InternalOnRightClick
End Object
lb_VoteCountListBox=DHMapVoteCountMultiColumnListBox'DH_Interface.DHMapVotingPage.VoteCountListBox'
Expand All @@ -183,8 +232,9 @@ defaultproperties
End Object
i_MapCountListBackground=GUIImage'DH_Interface.DHMapVotingPage.MapCountListBackground'


Begin Object class=moEditBox Name=FilterEditbox
WinWidth=0.86
WinWidth=0.41
WinHeight=0.12
WinLeft=0.02
WinTop=0.90
Expand All @@ -200,7 +250,7 @@ defaultproperties
Begin Object Class=GUIButton Name=FilterClearButton
WinWidth=0.08
WinHeight=0.04
WinLeft=0.90
WinLeft=0.44
WinTop=0.894
Caption="Clear"
FontScale=FNS_Small
Expand All @@ -212,5 +262,45 @@ defaultproperties
End Object
b_FilterClear=FilterClearButton

Begin Object Class=GUILabel Name=MapPreviewName
WinWidth=0.35
WinHeight=0.1
WinLeft=0.53
WinTop=0.125
TextAlign=TXTA_Left
TextColor=(R=255,G=255,B=255,A=255)
TextFont="DHMenuFont"
Caption="Map Preview"
End Object
l_MapPreviewName=MapPreviewName

Begin Object Class=GUIImage Name=MapPreviewImage
WinWidth=0.352002
WinHeight=0.337480
WinLeft=0.53
WinTop=0.2
ImageColor=(R=255,G=255,B=255,A=255)
ImageStyle=ISTY_Scaled
ImageRenderStyle=MSTY_Normal
RenderWeight=0.2
End Object
i_MapPreviewImage=MapPreviewImage

Begin Object Class=DHGUIScrollTextBox Name=MapPreviewDesc
bNoTeletype=true
CharDelay=0.0025
EOLDelay=0.5
OnCreateComponent=MapPreviewDesc.InternalOnCreateComponent
FontScale=FNS_Small
StyleName="DHLargeText"
WinWidth=0.358001
WinHeight=0.31
WinLeft=0.525
WinTop=0.545
bTabStop=false
bNeverFocus=true
End Object
lb_MapPreviewDesc=MapPreviewDesc

f_Chat=none
}