mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 00:26:28 -04:00
Can configure most keys now. (excluding pause and function keys)
This commit is contained in:
parent
908c3c4ade
commit
1ed45db594
@ -9,14 +9,16 @@ namespace ClassicalSharp {
|
|||||||
public PauseScreen( Game window ) : base( window ) {
|
public PauseScreen( Game window ) : base( window ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWidget controlsWidget, gameWidget, exitWidget;
|
TextWidget controlsWidget, gameWidget, exitWidget, keyStatusWidget;
|
||||||
TextWidget[] keysLeft, keysRight;
|
KeyMapWidget[] keysLeft, keysRight;
|
||||||
|
KeyMapWidget widgetToChange;
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
GraphicsApi.Draw2DQuad( 0, 0, Window.Width, Window.Height, new FastColour( 255, 255, 255, 100 ) );
|
GraphicsApi.Draw2DQuad( 0, 0, Window.Width, Window.Height, new FastColour( 255, 255, 255, 100 ) );
|
||||||
controlsWidget.Render( delta );
|
controlsWidget.Render( delta );
|
||||||
gameWidget.Render( delta );
|
gameWidget.Render( delta );
|
||||||
exitWidget.Render( delta );
|
exitWidget.Render( delta );
|
||||||
|
keyStatusWidget.Render( delta );
|
||||||
for( int i = 0; i < keysLeft.Length; i++ ) {
|
for( int i = 0; i < keysLeft.Length; i++ ) {
|
||||||
keysLeft[i].Render( delta );
|
keysLeft[i].Render( delta );
|
||||||
}
|
}
|
||||||
@ -26,9 +28,10 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
controlsWidget = CreateTextWidget( 0, 30, "&eControls list", Docking.LeftOrTop, 16, FontStyle.Bold );
|
controlsWidget = CreateTextWidget( 0, 30, "&eControls list", Docking.Centre, Docking.LeftOrTop, 16, FontStyle.Bold );
|
||||||
gameWidget = CreateTextWidget( 0, -60, "&eBack to game", Docking.BottomOrRight, 16, FontStyle.Bold );
|
keyStatusWidget = CreateTextWidget( 0, -80, "", Docking.Centre, Docking.BottomOrRight, 13, FontStyle.Italic );
|
||||||
exitWidget = CreateTextWidget( 0, -10, "&eExit", Docking.BottomOrRight, 16, FontStyle.Bold );
|
gameWidget = CreateTextWidget( 0, -50, "&eBack to game", Docking.Centre, Docking.BottomOrRight, 16, FontStyle.Bold );
|
||||||
|
exitWidget = CreateTextWidget( 0, -10, "&eExit", Docking.Centre, Docking.BottomOrRight, 16, FontStyle.Bold );
|
||||||
|
|
||||||
KeyMapping[] mappingsLeft = { KeyMapping.Forward, KeyMapping.Back, KeyMapping.Left, KeyMapping.Right,
|
KeyMapping[] mappingsLeft = { KeyMapping.Forward, KeyMapping.Back, KeyMapping.Left, KeyMapping.Right,
|
||||||
KeyMapping.Jump, KeyMapping.Respawn, KeyMapping.SetSpawn, KeyMapping.OpenChat, KeyMapping.SendChat,
|
KeyMapping.Jump, KeyMapping.Respawn, KeyMapping.SetSpawn, KeyMapping.OpenChat, KeyMapping.SendChat,
|
||||||
@ -37,36 +40,38 @@ namespace ClassicalSharp {
|
|||||||
"Open chat", "Send chat", "Pause", "Open inventory" };
|
"Open chat", "Send chat", "Pause", "Open inventory" };
|
||||||
MakeKeysLeft( mappingsLeft, descriptionsLeft );
|
MakeKeysLeft( mappingsLeft, descriptionsLeft );
|
||||||
|
|
||||||
KeyMapping[] mappingsRight = { KeyMapping.Screenshot, KeyMapping.Fullscreen, KeyMapping.ThirdPersonCamera,
|
KeyMapping[] mappingsRight = { KeyMapping.Screenshot, KeyMapping.Fullscreen, KeyMapping.ThirdPersonCamera,
|
||||||
KeyMapping.VSync, KeyMapping.ViewDistance, KeyMapping.Fly, KeyMapping.Speed, KeyMapping.NoClip,
|
KeyMapping.VSync, KeyMapping.ViewDistance, KeyMapping.Fly, KeyMapping.Speed, KeyMapping.NoClip,
|
||||||
KeyMapping.FlyUp, KeyMapping.FlyDown, KeyMapping.PlayerList };
|
KeyMapping.FlyUp, KeyMapping.FlyDown, KeyMapping.PlayerList };
|
||||||
string[] descriptionsRight = { "Take screenshot", "Toggle fullscreen", "Toggle 3rd person camera", "Toggle VSync",
|
string[] descriptionsRight = { "Take screenshot", "Toggle fullscreen", "Toggle 3rd person camera", "Toggle VSync",
|
||||||
"Change view distance", "Toggle fly", "Speed", "Toggle noclip", "Fly up", "Fly down", "Display player list" };
|
"Change view distance", "Toggle fly", "Speed", "Toggle noclip", "Fly up", "Fly down", "Display player list" };
|
||||||
MakeKeysRight( mappingsRight, descriptionsRight );
|
MakeKeysRight( mappingsRight, descriptionsRight );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int leftEnd;
|
||||||
void MakeKeysLeft( KeyMapping[] mappings, string[] descriptions ) {
|
void MakeKeysLeft( KeyMapping[] mappings, string[] descriptions ) {
|
||||||
int startY = controlsWidget.BottomRight.Y + 10;
|
int startY = controlsWidget.BottomRight.Y + 10;
|
||||||
keysLeft = new TextWidget[mappings.Length];
|
keysLeft = new KeyMapWidget[mappings.Length];
|
||||||
for( int i = 0; i < keysLeft.Length; i++ ) {
|
for( int i = 0; i < keysLeft.Length; i++ ) {
|
||||||
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
|
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
|
||||||
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, 14, FontStyle.Bold );
|
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, Docking.LeftOrTop, 14, FontStyle.Bold );
|
||||||
widget.XOffset = -widget.Width / 2 - 20;
|
widget.XOffset = 10;
|
||||||
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
|
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
|
||||||
keysLeft[i] = widget;
|
keysLeft[i] = new KeyMapWidget( widget, mappings[i], descriptions[i] );
|
||||||
startY += widget.Height + 5;
|
startY += widget.Height + 5;
|
||||||
}
|
}
|
||||||
|
leftEnd = CalculateMaxWidth( keysLeft );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeKeysRight( KeyMapping[] mappings, string[] descriptions ) {
|
void MakeKeysRight( KeyMapping[] mappings, string[] descriptions ) {
|
||||||
int startY = controlsWidget.BottomRight.Y + 10;
|
int startY = controlsWidget.BottomRight.Y + 10;
|
||||||
keysRight = new TextWidget[mappings.Length];
|
keysRight = new KeyMapWidget[mappings.Length];
|
||||||
for( int i = 0; i < keysRight.Length; i++ ) {
|
for( int i = 0; i < keysRight.Length; i++ ) {
|
||||||
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
|
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
|
||||||
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, 14, FontStyle.Bold );
|
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, Docking.LeftOrTop, 14, FontStyle.Bold );
|
||||||
widget.XOffset = widget.Width / 2 + 20;
|
widget.XOffset = leftEnd + 30;
|
||||||
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
|
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
|
||||||
keysRight[i] = widget;
|
keysRight[i] = new KeyMapWidget( widget, mappings[i], descriptions[i] );
|
||||||
startY += widget.Height + 5;
|
startY += widget.Height + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,11 +88,11 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWidget CreateTextWidget( int x, int y, string text, Docking vertical, int fontSize, FontStyle style ) {
|
TextWidget CreateTextWidget( int x, int y, string text, Docking horizontal, Docking vertical, int fontSize, FontStyle style ) {
|
||||||
TextWidget widget = new TextWidget( Window, fontSize );
|
TextWidget widget = new TextWidget( Window, fontSize );
|
||||||
widget.Style = style;
|
widget.Style = style;
|
||||||
widget.Init();
|
widget.Init();
|
||||||
widget.HorizontalDocking = Docking.Centre;
|
widget.HorizontalDocking = horizontal;
|
||||||
widget.VerticalDocking = vertical;
|
widget.VerticalDocking = vertical;
|
||||||
widget.XOffset = x;
|
widget.XOffset = x;
|
||||||
widget.YOffset = y;
|
widget.YOffset = y;
|
||||||
@ -99,6 +104,7 @@ namespace ClassicalSharp {
|
|||||||
gameWidget.OnResize( oldWidth, oldHeight, width, height );
|
gameWidget.OnResize( oldWidth, oldHeight, width, height );
|
||||||
controlsWidget.OnResize( oldWidth, oldHeight, width, height );
|
controlsWidget.OnResize( oldWidth, oldHeight, width, height );
|
||||||
exitWidget.OnResize( oldWidth, oldHeight, width, height );
|
exitWidget.OnResize( oldWidth, oldHeight, width, height );
|
||||||
|
keyStatusWidget.OnResize( oldWidth, oldHeight, width, height );
|
||||||
for( int i = 0; i < keysLeft.Length; i++ ) {
|
for( int i = 0; i < keysLeft.Length; i++ ) {
|
||||||
keysLeft[i].OnResize( oldWidth, oldHeight, width, height );
|
keysLeft[i].OnResize( oldWidth, oldHeight, width, height );
|
||||||
}
|
}
|
||||||
@ -111,6 +117,49 @@ namespace ClassicalSharp {
|
|||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
|
if( widgetToChange != null ) {
|
||||||
|
KeyMapWidget widget = widgetToChange;
|
||||||
|
widgetToChange = null;
|
||||||
|
string reason;
|
||||||
|
if( !Window.Keys.IsKeyOkay( key, out reason ) ) {
|
||||||
|
const string format = "&eFailed to change mapping \"{0}\". &c({1})";
|
||||||
|
keyStatusWidget.SetText( String.Format( format, widget.Description, reason ) );
|
||||||
|
} else {
|
||||||
|
Key oldKey = Window.Keys[widget.Mapping];
|
||||||
|
const string format = "&eChanged mapping \"{0}\" from &7{1} &eto &7{2}&e.";
|
||||||
|
keyStatusWidget.SetText( String.Format( format, widget.Description, oldKey, key ) );
|
||||||
|
Window.Keys[widget.Mapping] = key;
|
||||||
|
widget.Widget.SetText( widget.Description + ": " + key );
|
||||||
|
if( Array.IndexOf( keysLeft, widget ) >= 0 ) {
|
||||||
|
ResizeKeysRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeKeysRight() {
|
||||||
|
int newLeftEnd = CalculateMaxWidth( keysLeft );
|
||||||
|
if( newLeftEnd != leftEnd ) {
|
||||||
|
int diff = newLeftEnd - leftEnd;
|
||||||
|
for( int i = 0; i < keysRight.Length; i++ ) {
|
||||||
|
TextWidget textWidget = keysRight[i].Widget;
|
||||||
|
textWidget.XOffset = newLeftEnd + 30;
|
||||||
|
textWidget.MoveTo( textWidget.X + diff, textWidget.Y );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
leftEnd = newLeftEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CalculateMaxWidth( KeyMapWidget[] widgets ) {
|
||||||
|
int maxWidth = 0;
|
||||||
|
for( int i = 0; i < widgets.Length; i++ ) {
|
||||||
|
maxWidth = Math.Max( widgets[i].Widget.Width, maxWidth );
|
||||||
|
}
|
||||||
|
return maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
if( button != MouseButton.Left ) return false;
|
if( button != MouseButton.Left ) return false;
|
||||||
if( exitWidget.ContainsPoint( mouseX, mouseY ) ) {
|
if( exitWidget.ContainsPoint( mouseX, mouseY ) ) {
|
||||||
@ -119,8 +168,59 @@ namespace ClassicalSharp {
|
|||||||
} else if( gameWidget.ContainsPoint( mouseX, mouseY ) ) {
|
} else if( gameWidget.ContainsPoint( mouseX, mouseY ) ) {
|
||||||
Window.SetNewScreen( new NormalScreen( Window ) );
|
Window.SetNewScreen( new NormalScreen( Window ) );
|
||||||
return true;
|
return true;
|
||||||
|
} else if( widgetToChange == null ) {
|
||||||
|
for( int i = 0; i < keysLeft.Length; i++ ) {
|
||||||
|
KeyMapWidget widget = keysLeft[i];
|
||||||
|
if( widget.Widget.ContainsPoint( mouseX, mouseY ) ) {
|
||||||
|
SetWidgetToChange( widget );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for( int i = 0; i < keysRight.Length; i++ ) {
|
||||||
|
KeyMapWidget widget = keysRight[i];
|
||||||
|
if( widget.Widget.ContainsPoint( mouseX, mouseY ) ) {
|
||||||
|
SetWidgetToChange( widget );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetWidgetToChange( KeyMapWidget widget ) {
|
||||||
|
Key oldKey = Window.Keys[widget.Mapping];
|
||||||
|
if( !Window.Keys.IsLockedKey( oldKey ) ) {
|
||||||
|
const string format = "&ePress new key for \"{0}\".";
|
||||||
|
keyStatusWidget.SetText( String.Format( format, widget.Description ) );
|
||||||
|
widgetToChange = widget;
|
||||||
|
} else {
|
||||||
|
const string format = "&cCannot change mapping of &e\"{0}\".";
|
||||||
|
keyStatusWidget.SetText( String.Format( format, widget.Description ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KeyMapWidget {
|
||||||
|
public TextWidget Widget;
|
||||||
|
public KeyMapping Mapping;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
public KeyMapWidget( TextWidget widget, KeyMapping mapping, string desc ) {
|
||||||
|
Widget = widget;
|
||||||
|
Mapping = mapping;
|
||||||
|
Description = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Render( double delta ) {
|
||||||
|
Widget.Render( delta );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||||
|
Widget.OnResize( oldWidth, oldHeight, width, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() {
|
||||||
|
Widget.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,184 +1,184 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
|
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>ClassicalSharp</RootNamespace>
|
<RootNamespace>ClassicalSharp</RootNamespace>
|
||||||
<AssemblyName>ClassicalSharp</AssemblyName>
|
<AssemblyName>ClassicalSharp</AssemblyName>
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<NoStdLib>False</NoStdLib>
|
<NoStdLib>False</NoStdLib>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
<UpgradeBackupLocation>
|
<UpgradeBackupLocation>
|
||||||
</UpgradeBackupLocation>
|
</UpgradeBackupLocation>
|
||||||
<OldToolsVersion>3.5</OldToolsVersion>
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>false</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
<UpdateMode>Foreground</UpdateMode>
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>7</UpdateInterval>
|
||||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
<UpdatePeriodically>false</UpdatePeriodically>
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
<RunCodeAnalysis>False</RunCodeAnalysis>
|
<RunCodeAnalysis>False</RunCodeAnalysis>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<RegisterForComInterop>False</RegisterForComInterop>
|
<RegisterForComInterop>False</RegisterForComInterop>
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||||
<BaseAddress>4194304</BaseAddress>
|
<BaseAddress>4194304</BaseAddress>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<OutputPath>output\debug\</OutputPath>
|
<OutputPath>output\debug\</OutputPath>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>Full</DebugType>
|
<DebugType>Full</DebugType>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<StartAction>Project</StartAction>
|
<StartAction>Project</StartAction>
|
||||||
<StartArguments>wwwf null 127.0.0.1 25566</StartArguments>
|
<StartArguments>wwwf null 127.0.0.1 25566</StartArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<OutputPath>output\release\</OutputPath>
|
<OutputPath>output\release\</OutputPath>
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
<DebugType>None</DebugType>
|
<DebugType>None</DebugType>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="OpenTK">
|
<Reference Include="OpenTK">
|
||||||
<HintPath>OpenTK.dll</HintPath>
|
<HintPath>OpenTK.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="2D\DrawTextArgs.cs" />
|
<Compile Include="2D\DrawTextArgs.cs" />
|
||||||
<Compile Include="2D\Screens\BlockSelectScreen.cs" />
|
<Compile Include="2D\Screens\BlockSelectScreen.cs" />
|
||||||
<Compile Include="2D\Screens\ChatScreen.cs" />
|
<Compile Include="2D\Screens\ChatScreen.cs" />
|
||||||
<Compile Include="2D\Screens\ErrorScreen.cs" />
|
<Compile Include="2D\Screens\ErrorScreen.cs" />
|
||||||
<Compile Include="2D\Screens\FpsScreen.cs" />
|
<Compile Include="2D\Screens\FpsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
|
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
|
||||||
<Compile Include="2D\Screens\NormalScreen.cs" />
|
<Compile Include="2D\Screens\NormalScreen.cs" />
|
||||||
<Compile Include="2D\Screens\PauseScreen.cs" />
|
<Compile Include="2D\Screens\PauseScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Screen.cs" />
|
<Compile Include="2D\Screens\Screen.cs" />
|
||||||
<Compile Include="2D\Utils2D.cs" />
|
<Compile Include="2D\Utils2D.cs" />
|
||||||
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
|
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\ExtPlayerListWidget.cs" />
|
<Compile Include="2D\Widgets\ExtPlayerListWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\PlayerListWidget.cs" />
|
<Compile Include="2D\Widgets\PlayerListWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\TextGroupWidget.cs" />
|
<Compile Include="2D\Widgets\TextGroupWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\TextInputWidget.cs" />
|
<Compile Include="2D\Widgets\TextInputWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\TextWidget.cs" />
|
<Compile Include="2D\Widgets\TextWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\Widget.cs" />
|
<Compile Include="2D\Widgets\Widget.cs" />
|
||||||
<Compile Include="Blocks\Block.cs" />
|
<Compile Include="Blocks\Block.cs" />
|
||||||
<Compile Include="Blocks\BlockInfo.cs" />
|
<Compile Include="Blocks\BlockInfo.cs" />
|
||||||
<Compile Include="Blocks\BlockInfo.Optimised.cs" />
|
<Compile Include="Blocks\BlockInfo.Optimised.cs" />
|
||||||
<Compile Include="Entities\Entity.cs" />
|
<Compile Include="Entities\Entity.cs" />
|
||||||
<Compile Include="Entities\LocalPlayer.cs" />
|
<Compile Include="Entities\LocalPlayer.cs" />
|
||||||
<Compile Include="Entities\ModelPart.cs" />
|
<Compile Include="Entities\ModelPart.cs" />
|
||||||
<Compile Include="Entities\NetPlayer.cs" />
|
<Compile Include="Entities\NetPlayer.cs" />
|
||||||
<Compile Include="Entities\Particle.cs" />
|
<Compile Include="Entities\Particle.cs" />
|
||||||
<Compile Include="Entities\ParticleManager.cs" />
|
<Compile Include="Entities\ParticleManager.cs" />
|
||||||
<Compile Include="Entities\Player.cs" />
|
<Compile Include="Entities\Player.cs" />
|
||||||
<Compile Include="Entities\PlayerModel.cs" />
|
<Compile Include="Entities\PlayerModel.cs" />
|
||||||
<Compile Include="Game\Game.Chat.cs" />
|
<Compile Include="Game\Game.Chat.cs" />
|
||||||
<Compile Include="Game\Game.cs" />
|
<Compile Include="Game\Game.cs" />
|
||||||
<Compile Include="Game\Game.Events.cs" />
|
<Compile Include="Game\Game.Events.cs" />
|
||||||
<Compile Include="Game\Game.InputHandling.cs" />
|
<Compile Include="Game\Game.InputHandling.cs" />
|
||||||
<Compile Include="GraphicsAPI\DirectXApi.cs" />
|
<Compile Include="GraphicsAPI\DirectXApi.cs" />
|
||||||
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
|
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
|
||||||
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
|
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
|
||||||
<Compile Include="Camera.cs" />
|
<Compile Include="Camera.cs" />
|
||||||
<Compile Include="Commands\Command.cs" />
|
<Compile Include="Commands\Command.cs" />
|
||||||
<Compile Include="Commands\DefaultCommands.cs" />
|
<Compile Include="Commands\DefaultCommands.cs" />
|
||||||
<Compile Include="FastBitmap.cs" />
|
<Compile Include="FastBitmap.cs" />
|
||||||
<Compile Include="FastColour.cs" />
|
<Compile Include="FastColour.cs" />
|
||||||
<Compile Include="GraphicsAPI\VertexFormats.cs" />
|
<Compile Include="GraphicsAPI\VertexFormats.cs" />
|
||||||
<Compile Include="Map.cs" />
|
<Compile Include="Map.cs" />
|
||||||
<Compile Include="MeshBuilders\ChunkMeshBuilder.cs" />
|
<Compile Include="MeshBuilders\ChunkMeshBuilder.cs" />
|
||||||
<Compile Include="MeshBuilders\ChunkMeshBuilderTex2Col4.cs" />
|
<Compile Include="MeshBuilders\ChunkMeshBuilderTex2Col4.cs" />
|
||||||
<Compile Include="Network\Enums.cs" />
|
<Compile Include="Network\Enums.cs" />
|
||||||
<Compile Include="Network\FastNetReader.cs" />
|
<Compile Include="Network\FastNetReader.cs" />
|
||||||
<Compile Include="Network\FixedBufferStream.cs" />
|
<Compile Include="Network\FixedBufferStream.cs" />
|
||||||
<Compile Include="Network\NetworkProcessor.cs" />
|
<Compile Include="Network\NetworkProcessor.cs" />
|
||||||
<Compile Include="Network\AsyncDownloader.cs" />
|
<Compile Include="Network\AsyncDownloader.cs" />
|
||||||
<Compile Include="Network\WomConfigHandler.cs" />
|
<Compile Include="Network\WomConfigHandler.cs" />
|
||||||
<Compile Include="Commands\CommandManager.cs" />
|
<Compile Include="Commands\CommandManager.cs" />
|
||||||
<Compile Include="Commands\CommandReader.cs" />
|
<Compile Include="Commands\CommandReader.cs" />
|
||||||
<Compile Include="Physics\BoundingBox.cs" />
|
<Compile Include="Physics\BoundingBox.cs" />
|
||||||
<Compile Include="Physics\Entity.Physics.cs" />
|
<Compile Include="Physics\Entity.Physics.cs" />
|
||||||
<Compile Include="Physics\IntersectionUtils.cs" />
|
<Compile Include="Physics\IntersectionUtils.cs" />
|
||||||
<Compile Include="Physics\Picking.cs" />
|
<Compile Include="Physics\Picking.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Rendering\LegacyEnvRenderer.cs" />
|
<Compile Include="Rendering\LegacyEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\LegacyMapEnvRenderer.cs" />
|
<Compile Include="Rendering\LegacyMapEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\EnvRenderer.cs" />
|
<Compile Include="Rendering\EnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\LegacyFastEnvRenderer.cs" />
|
<Compile Include="Rendering\LegacyFastEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\FrustumCulling.cs" />
|
<Compile Include="Rendering\FrustumCulling.cs" />
|
||||||
<Compile Include="Rendering\MapEnvRenderer.cs" />
|
<Compile Include="Rendering\MapEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\MapRenderer.cs" />
|
<Compile Include="Rendering\MapRenderer.cs" />
|
||||||
<Compile Include="Rendering\NormalEnvRenderer.cs" />
|
<Compile Include="Rendering\NormalEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\PickingRenderer.cs" />
|
<Compile Include="Rendering\PickingRenderer.cs" />
|
||||||
<Compile Include="Rendering\PlayerRenderer.cs" />
|
<Compile Include="Rendering\PlayerRenderer.cs" />
|
||||||
<Compile Include="Rendering\NormalMapEnvRenderer.cs" />
|
<Compile Include="Rendering\NormalMapEnvRenderer.cs" />
|
||||||
<Compile Include="Selections\SelectionBox.cs" />
|
<Compile Include="Selections\SelectionBox.cs" />
|
||||||
<Compile Include="Selections\SelectionManager.cs" />
|
<Compile Include="Selections\SelectionManager.cs" />
|
||||||
<Compile Include="TextureAtlas2D.cs" />
|
<Compile Include="TextureAtlas2D.cs" />
|
||||||
<Compile Include="TextureAtlas1D.cs" />
|
<Compile Include="TextureAtlas1D.cs" />
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
<ProductName>Windows Installer 3.1</ProductName>
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="2D\Screens" />
|
<Folder Include="2D\Screens" />
|
||||||
<Folder Include="2D\Widgets" />
|
<Folder Include="2D\Widgets" />
|
||||||
<Folder Include="Blocks" />
|
<Folder Include="Blocks" />
|
||||||
<Folder Include="GraphicsAPI" />
|
<Folder Include="GraphicsAPI" />
|
||||||
<Folder Include="Entities" />
|
<Folder Include="Entities" />
|
||||||
<Folder Include="MeshBuilders" />
|
<Folder Include="MeshBuilders" />
|
||||||
<Folder Include="Game" />
|
<Folder Include="Game" />
|
||||||
<Folder Include="Physics" />
|
<Folder Include="Physics" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -79,7 +79,7 @@ namespace ClassicalSharp {
|
|||||||
} else if( key == Keys[KeyMapping.Fullscreen] ) {
|
} else if( key == Keys[KeyMapping.Fullscreen] ) {
|
||||||
WindowState state = WindowState;
|
WindowState state = WindowState;
|
||||||
if( state != WindowState.Minimized ) {
|
if( state != WindowState.Minimized ) {
|
||||||
WindowState = state == WindowState.Fullscreen ?
|
WindowState = state == WindowState.Fullscreen ?
|
||||||
WindowState.Normal : WindowState.Fullscreen;
|
WindowState.Normal : WindowState.Fullscreen;
|
||||||
}
|
}
|
||||||
} else if( key == Keys[KeyMapping.ThirdPersonCamera] ) {
|
} else if( key == Keys[KeyMapping.ThirdPersonCamera] ) {
|
||||||
@ -147,58 +147,54 @@ namespace ClassicalSharp {
|
|||||||
return block == 0 || ( !CanPlace[block] && !CanDelete[block] && BlockInfo.IsLiquid( block ) );
|
return block == 0 || ( !CanPlace[block] && !CanDelete[block] && BlockInfo.IsLiquid( block ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyMap Keys = new KeyMap();
|
public KeyMap Keys = new KeyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class KeyMap {
|
public class KeyMap {
|
||||||
|
|
||||||
public Key this[KeyMapping key] {
|
public Key this[KeyMapping key] {
|
||||||
get { return Keys[(int)key]; }
|
get { return Keys[(int)key]; }
|
||||||
set { Keys[(int)key] = value; }
|
set { Keys[(int)key] = value; }
|
||||||
}
|
|
||||||
|
|
||||||
Key[] Keys = new Key[] {
|
|
||||||
Key.W, Key.S, Key.A, Key.D, Key.Space, Key.R, Key.Y, Key.T,
|
|
||||||
Key.Enter, Key.Escape, Key.B, Key.F12, Key.F11, Key.F7,
|
|
||||||
Key.F5, Key.F6, Key.Z, Key.LShift, Key.X, Key.Q, Key.E,
|
|
||||||
Key.Tab, Key.H,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool IsLockedKey( Key key ) {
|
|
||||||
return key == Key.Escape || ( key >= Key.F1 && key <= Key.F35 );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsReservedKey( Key key ) {
|
|
||||||
return key == Key.Slash || key == Key.BackSpace ||
|
|
||||||
( key >= Key.Insert && key <= Key.End ) ||
|
|
||||||
( key >= Key.Up && key <= Key.Right ) || // chat screen movement
|
|
||||||
( key >= Key.Number0 && key <= Key.Number9 ); // block hotbar
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsKeyOkay( Key key, out string reason ) {
|
|
||||||
if( IsLockedKey( key ) ) {
|
|
||||||
reason = "Given key mapping cannot be changed.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if( IsReservedKey( key ) ) {
|
|
||||||
reason = "Given key is reserved for gui.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for( int i = 0; i < Keys.Length; i++ ) {
|
|
||||||
if( Keys[i] == key ) {
|
|
||||||
reason = "Key is already assigned.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reason = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum KeyMapping {
|
Key[] Keys = new Key[] {
|
||||||
Forward, Back, Left, Right, Jump, Respawn, SetSpawn, OpenChat,
|
Key.W, Key.S, Key.A, Key.D, Key.Space, Key.R, Key.Y, Key.T,
|
||||||
SendChat, PauseOrExit, OpenInventory, Screenshot, Fullscreen, VSync,
|
Key.Enter, Key.Escape, Key.B, Key.F12, Key.F11, Key.F7,
|
||||||
ThirdPersonCamera, ViewDistance, Fly, Speed, NoClip, FlyUp, FlyDown,
|
Key.F5, Key.F6, Key.Z, Key.LShift, Key.X, Key.Q, Key.E,
|
||||||
PlayerList, ChatHistoryMode,
|
Key.Tab, Key.H,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool IsReservedKey( Key key ) {
|
||||||
|
return key == Key.Slash || key == Key.BackSpace ||
|
||||||
|
( key >= Key.Insert && key <= Key.End ) ||
|
||||||
|
( key >= Key.Up && key <= Key.Right ) || // chat screen movement
|
||||||
|
( key >= Key.Number0 && key <= Key.Number9 ); // block hotbar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsLockedKey( Key key ) {
|
||||||
|
return key == Key.Escape || ( key >= Key.F1 && key <= Key.F35 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsKeyOkay( Key key, out string reason ) {
|
||||||
|
if( IsReservedKey( key ) ) {
|
||||||
|
reason = "Given key is reserved for gui";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for( int i = 0; i < Keys.Length; i++ ) {
|
||||||
|
if( Keys[i] == key ) {
|
||||||
|
reason = "Key is already assigned";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reason = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum KeyMapping {
|
||||||
|
Forward, Back, Left, Right, Jump, Respawn, SetSpawn, OpenChat,
|
||||||
|
SendChat, PauseOrExit, OpenInventory, Screenshot, Fullscreen, VSync,
|
||||||
|
ThirdPersonCamera, ViewDistance, Fly, Speed, NoClip, FlyUp, FlyDown,
|
||||||
|
PlayerList, ChatHistoryMode,
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user