Skip to content

Commit

Permalink
feat(ui): add controller layout options
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Jan 11, 2023
1 parent e1f0791 commit 1de30e0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 21 deletions.
6 changes: 3 additions & 3 deletions MHFZ_Overlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@
<value>610</value>
</setting>
<setting name="ControllerLayoutShown" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="ControllerLayoutX" serializeAs="String">
<value>0</value>
<value>160</value>
</setting>
<setting name="ControllerLayoutY" serializeAs="String">
<value>0</value>
<value>550</value>
</setting>
<setting name="EnableKeyLogging" serializeAs="String">
<value>False</value>
Expand Down
34 changes: 24 additions & 10 deletions MHFZ_Overlay/ConfigWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>

<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>

</Grid.RowDefinitions>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="0" Grid.Column="0" Text="Max Resolution Width"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="0" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=MaxResolutionWidth}" PreviewTextInput="ValidateNumber"/>
Expand Down Expand Up @@ -310,16 +316,24 @@
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="31" Grid.Column="0" Text="Keyboard and Mouse Layout Y Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="31" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=KBMLayoutY}" PreviewTextInput="ValidateNumber"/>

<TextBlock Margin="5,5,5,5" ToolTip="Show Actions Per Minute (actions are defined as the total sum of keystrokes, mouse button presses and controller inputs)" Style="{StaticResource ConfigTextBox}" Grid.Row="32" Grid.Column="0" Text="Actions per Minute"/>
<ToggleButton Grid.Row="32" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=ActionsPerMinuteShown}"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="33" Grid.Column="0" Text="Actions per Minute X Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="33" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteX}" PreviewTextInput="ValidateNumber"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="34" Grid.Column="0" Text="Actions per Minute Y Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="34" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteY}" PreviewTextInput="ValidateNumber"/>
<TextBlock Margin="5,5,5,5" ToolTip="Enable Actions per Minute color when surpassing the average actions per minute of the equipped weapon type" Style="{StaticResource ConfigTextBox}" Grid.Row="35" Grid.Column="0" Text="Average Actions per Minute Color"/>
<ToggleButton Grid.Row="35" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=EnableAverageActionsPerMinuteColor}"/>
<TextBlock Margin="5,5,5,5" ToolTip="Show Gamepad Layout" Style="{StaticResource ConfigTextBox}" Grid.Row="32" Grid.Column="0" Text="Controller/Gamepad Layout"/>
<ToggleButton Grid.Row="32" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=ControllerLayoutShown}"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="33" Grid.Column="0" Text="Controller/Gamepad Layout X Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="33" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ControllerLayoutX}" PreviewTextInput="ValidateNumber"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="34" Grid.Column="0" Text="Controller/Gamepad Layout Y Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="34" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ControllerLayoutY}" PreviewTextInput="ValidateNumber"/>


<TextBlock Margin="5,5,5,5" ToolTip="Show Actions Per Minute (actions are defined as the total sum of keystrokes, mouse button presses and controller inputs)" Style="{StaticResource ConfigTextBox}" Grid.Row="35" Grid.Column="0" Text="Actions per Minute"/>
<ToggleButton Grid.Row="35" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=ActionsPerMinuteShown}"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="36" Grid.Column="0" Text="Actions per Minute X Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="36" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteX}" PreviewTextInput="ValidateNumber"/>
<TextBlock Margin="5,5,5,5" Style="{StaticResource ConfigTextBox}" Grid.Row="37" Grid.Column="0" Text="Actions per Minute Y Coordinate"/>
<TextBox IsUndoEnabled="False" TextAlignment="Center" Background="#585b70" Style="{StaticResource ConfigTextField}" Grid.Row="37" Grid.Column="1" Text="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteY}" PreviewTextInput="ValidateNumber"/>
<TextBlock Margin="5,5,5,5" ToolTip="Enable Actions per Minute color when surpassing the average actions per minute of the equipped weapon type" Style="{StaticResource ConfigTextBox}" Grid.Row="38" Grid.Column="0" Text="Average Actions per Minute Color"/>
<ToggleButton Grid.Row="38" Grid.Column="1" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding Source={StaticResource Settings}, Path=EnableAverageActionsPerMinuteColor}"/>

<Button Grid.Row="36" Grid.Column="0" Grid.ColumnSpan="2" Content="Export user settings to JSON file" Click="ExportUserSettings_Click"/>
<Button Grid.Row="39" Grid.Column="0" Grid.ColumnSpan="2" Content="Export user settings to JSON file" Click="ExportUserSettings_Click"/>
</Grid>
</ScrollViewer>
<Grid Background="Transparent" Grid.Row="1" Grid.ColumnSpan="1">
Expand Down
36 changes: 35 additions & 1 deletion MHFZ_Overlay/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<local:OutlinedTextBlock Visibility="{Binding ElementName=Window, Path=DataLoader.model.ShowOverlayStatText, Converter={StaticResource BoolToVis}}" HorizontalAlignment="Left" Text="{Binding QuestTimeMode}" Grid.Column="0" Grid.Row="0" FontFamily="MS Gothic" FontSize="21" FontWeight="Bold" StrokeThickness="4" Stroke="#1e1e2e" Fill="{Binding Source={StaticResource Settings},Path=TextColor}" />
<local:OutlinedTextBlock HorizontalAlignment="Left" Grid.Column="1" Grid.Row="0" FontFamily="{StaticResource Source Code Pro Bold}" FontSize="16" StrokeThickness="4" Stroke="#1e1e2e" Fill="{Binding isOnPace}" x:Name="timeRemainingTextBox" Text="{Binding Time}" Margin="4,0,0,0"/>
</Grid>
<Grid x:Name="ActionsPerMinuteInfo" Canvas.Left="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteX}" Canvas.Top="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteY}" Width="360" Height="30" MouseLeftButtonDown="ElementMouseLeftButtonDown" Background="{Binding Source={StaticResource Settings},Path=TextBackGroundColor}" Visibility="{Binding ElementName=Window, Path=DataLoader.model.ShowActionsPerMinute, Converter={StaticResource BoolToVis}}">
<Grid x:Name="ActionsPerMinuteInfo" Canvas.Left="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteX}" Canvas.Top="{Binding Source={StaticResource Settings},Path=ActionsPerMinuteY}" Width="360" Height="30" MouseLeftButtonDown="ElementMouseLeftButtonDown" Background="{Binding Source={StaticResource Settings},Path=TextBackGroundColor}" Visibility="{Binding ElementName=Window, Path=DataLoader.model.ShowAPM, Converter={StaticResource BoolToVis}}">
<Grid.ColumnDefinitions >
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="4*"/>
Expand Down Expand Up @@ -187,6 +187,40 @@
<Image x:Name="MouseMiddleClick" Opacity="0.2" Source="UI/Icons/png/middle_click.png" Grid.Row="4" Grid.Column="3"/>
<Image x:Name="MouseRightClick" Opacity="0.2" Source="UI/Icons/png/right_click.png" Grid.Row="4" Grid.Column="4"/>
</Grid>
<Grid Background="{Binding Source={StaticResource Settings},Path=HPBackGroundColor}" x:Name="ControllerLayoutGrid" Canvas.Left="{Binding Source={StaticResource Settings},Path=ControllerLayoutX}" Canvas.Top="{Binding Source={StaticResource Settings},Path=ControllerLayoutY}" Width="150" Height="150" MouseLeftButtonDown="ElementMouseLeftButtonDown"
Visibility="{Binding ElementName=Window, Path=DataLoader.model.ShowControllerLayout, Converter={StaticResource BoolToVis}}">
<Grid.ColumnDefinitions >
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Image x:Name="ButtonL2" Opacity="0.2" Source="UI/Icons/png/controller_l2.png" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Stretch="Fill"/>
<Image x:Name="ButtonR2" Opacity="0.2" Source="UI/Icons/png/controller_r2.png" Grid.Row="0" Grid.Column="5" Grid.ColumnSpan="2" Stretch="Fill"/>
<Image x:Name="ButtonL1" Opacity="0.2" Source="UI/Icons/png/controller_l1.png" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Stretch="Fill"/>
<Image x:Name="ButtonR1" Opacity="0.2" Source="UI/Icons/png/controller_r1.png" Grid.Row="1" Grid.Column="5" Grid.ColumnSpan="2" Stretch="Fill"/>
<Image x:Name="DPad" Opacity="0.2" Source="UI/Icons/png/controller_dpad.png" Grid.Row="2" Grid.Column="0" Grid.RowSpan="3" Grid.ColumnSpan="3" />
<Image x:Name="LJoystick" Opacity="0.2" Source="UI/Icons/png/controller_joystick.png" Grid.Row="4" Grid.RowSpan="2" Grid.Column="2" Grid.ColumnSpan="2"/>
<Image x:Name="RJoystick" Opacity="0.2" Source="UI/Icons/png/controller_joystick.png" Grid.Row="4" Grid.RowSpan="2" Grid.Column="4" Grid.ColumnSpan="2"/>
<Image x:Name="ButtonA" Opacity="0.2" Source="UI/Icons/png/controller_a.png" Grid.Row="4" Grid.Column="6"/>
<Image x:Name="ButtonB" Opacity="0.2" Source="UI/Icons/png/controller_b.png" Grid.Row="3" Grid.Column="7"/>
<Image x:Name="ButtonX" Opacity="0.2" Source="UI/Icons/png/controller_x.png" Grid.Row="3" Grid.Column="5"/>
<Image x:Name="ButtonY" Opacity="0.2" Source="UI/Icons/png/controller_y.png" Grid.Row="2" Grid.Column="6"/>
<Image x:Name="ButtonSelect" Opacity="0.2" Source="UI/Icons/png/controller_select.png" Grid.Row="3" Grid.Column="3"/>
<Image x:Name="ButtonStart" Opacity="0.2" Source="UI/Icons/png/controller_start.png" Grid.Row="3" Grid.Column="4"/>
</Grid>
<Grid Background="{Binding Source={StaticResource Settings},Path=HPBackGroundColor}" x:Name="Monster1HpBar" Canvas.Left="{Binding Source={StaticResource Settings},Path=Monster1HealthBarX}" Canvas.Top="{Binding Source={StaticResource Settings},Path=Monster1HealthBarY}" Width="500" Height="40" MouseLeftButtonDown="ElementMouseLeftButtonDown"
Visibility="{Binding ElementName=Window, Path=DataLoader.model.ShowMonster1HPBar, Converter={StaticResource BoolToVis}}">
<Grid.RowDefinitions>
Expand Down
7 changes: 7 additions & 0 deletions MHFZ_Overlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ private void HidePlayerInfoWhenNotInQuest()
DataLoader.model.ShowDamagePerSecond = v && s.DamagePerSecondShown;

DataLoader.model.ShowKBMLayout = v && s.KBMLayoutShown;
DataLoader.model.ShowControllerLayout = v && s.ControllerLayoutShown;
DataLoader.model.ShowAPM = v && s.ActionsPerMinuteShown;
}

Expand Down Expand Up @@ -2272,11 +2273,17 @@ private void MainGrid_DragOver(object sender, DragEventArgs e)
s.KBMLayoutX = (double)(pos.X - XOffset);
s.KBMLayoutY = (double)(pos.Y - XOffset);
break;
case "ControllerLayoutGrid":
s.ControllerLayoutX = (double)(pos.X - XOffset);
s.ControllerLayoutY = (double)(pos.Y - XOffset);
break;
case "ActionsPerMinuteInfo":
s.ActionsPerMinuteX = (double)(pos.X - XOffset);
s.ActionsPerMinuteY = (double)(pos.Y - XOffset);
break;


// Monster
case "Monster1HpBar":
s.Monster1HealthBarX = (double)(pos.X - XOffset);
s.Monster1HealthBarY = (double)(pos.Y - YOffset);
Expand Down
6 changes: 3 additions & 3 deletions MHFZ_Overlay/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions MHFZ_Overlay/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,13 @@
<Value Profile="(Default)">610</Value>
</Setting>
<Setting Name="ControllerLayoutShown" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ControllerLayoutX" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
<Value Profile="(Default)">160</Value>
</Setting>
<Setting Name="ControllerLayoutY" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
<Value Profile="(Default)">550</Value>
</Setting>
<Setting Name="EnableKeyLogging" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
Expand Down
3 changes: 2 additions & 1 deletion MHFZ_Overlay/addresses/AddressModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,8 @@ public string isPlayerHit
if (Dictionary.WeaponCanUseReflect.WeaponTypeID[WeaponType()])
hasReflect = true;

if (!hasReflect && TotalHitsTakenBlocked == 0 && ShowHitsTakenBlockedColor())
// for speedrunners to get hit by 1 small bomb at least. and 2 perfect guards to get max obscurity.
if ((!hasReflect && TotalHitsTakenBlocked <= 1) || (hasReflect && TotalHitsTakenBlocked <= 3) && ShowHitsTakenBlockedColor())
{
PlayerHitsTakenBlockedIcon = "UI/Icons/png/defense_up.png";
return "#f38ba8";
Expand Down

0 comments on commit 1de30e0

Please sign in to comment.