Can configure most keys now. (excluding pause and function keys)

This commit is contained in:
UnknownShadow200 2015-01-02 19:25:51 +11:00
parent 908c3c4ade
commit 1ed45db594
3 changed files with 345 additions and 249 deletions

View File

@ -9,14 +9,16 @@ namespace ClassicalSharp {
public PauseScreen( Game window ) : base( window ) {
}
TextWidget controlsWidget, gameWidget, exitWidget;
TextWidget[] keysLeft, keysRight;
TextWidget controlsWidget, gameWidget, exitWidget, keyStatusWidget;
KeyMapWidget[] keysLeft, keysRight;
KeyMapWidget widgetToChange;
public override void Render( double delta ) {
GraphicsApi.Draw2DQuad( 0, 0, Window.Width, Window.Height, new FastColour( 255, 255, 255, 100 ) );
controlsWidget.Render( delta );
gameWidget.Render( delta );
exitWidget.Render( delta );
keyStatusWidget.Render( delta );
for( int i = 0; i < keysLeft.Length; i++ ) {
keysLeft[i].Render( delta );
}
@ -26,9 +28,10 @@ namespace ClassicalSharp {
}
public override void Init() {
controlsWidget = CreateTextWidget( 0, 30, "&eControls list", Docking.LeftOrTop, 16, FontStyle.Bold );
gameWidget = CreateTextWidget( 0, -60, "&eBack to game", Docking.BottomOrRight, 16, FontStyle.Bold );
exitWidget = CreateTextWidget( 0, -10, "&eExit", Docking.BottomOrRight, 16, FontStyle.Bold );
controlsWidget = CreateTextWidget( 0, 30, "&eControls list", Docking.Centre, Docking.LeftOrTop, 16, FontStyle.Bold );
keyStatusWidget = CreateTextWidget( 0, -80, "", Docking.Centre, Docking.BottomOrRight, 13, FontStyle.Italic );
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.Jump, KeyMapping.Respawn, KeyMapping.SetSpawn, KeyMapping.OpenChat, KeyMapping.SendChat,
@ -37,36 +40,38 @@ namespace ClassicalSharp {
"Open chat", "Send chat", "Pause", "Open inventory" };
MakeKeysLeft( mappingsLeft, descriptionsLeft );
KeyMapping[] mappingsRight = { KeyMapping.Screenshot, KeyMapping.Fullscreen, KeyMapping.ThirdPersonCamera,
KeyMapping.VSync, KeyMapping.ViewDistance, KeyMapping.Fly, KeyMapping.Speed, KeyMapping.NoClip,
KeyMapping[] mappingsRight = { KeyMapping.Screenshot, KeyMapping.Fullscreen, KeyMapping.ThirdPersonCamera,
KeyMapping.VSync, KeyMapping.ViewDistance, KeyMapping.Fly, KeyMapping.Speed, KeyMapping.NoClip,
KeyMapping.FlyUp, KeyMapping.FlyDown, KeyMapping.PlayerList };
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" };
MakeKeysRight( mappingsRight, descriptionsRight );
}
int leftEnd;
void MakeKeysLeft( KeyMapping[] mappings, string[] descriptions ) {
int startY = controlsWidget.BottomRight.Y + 10;
keysLeft = new TextWidget[mappings.Length];
keysLeft = new KeyMapWidget[mappings.Length];
for( int i = 0; i < keysLeft.Length; i++ ) {
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, 14, FontStyle.Bold );
widget.XOffset = -widget.Width / 2 - 20;
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, Docking.LeftOrTop, 14, FontStyle.Bold );
widget.XOffset = 10;
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
keysLeft[i] = widget;
keysLeft[i] = new KeyMapWidget( widget, mappings[i], descriptions[i] );
startY += widget.Height + 5;
}
leftEnd = CalculateMaxWidth( keysLeft );
}
void MakeKeysRight( KeyMapping[] mappings, string[] descriptions ) {
int startY = controlsWidget.BottomRight.Y + 10;
keysRight = new TextWidget[mappings.Length];
keysRight = new KeyMapWidget[mappings.Length];
for( int i = 0; i < keysRight.Length; i++ ) {
string text = descriptions[i] + ": " + Window.Keys[mappings[i]];
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, 14, FontStyle.Bold );
widget.XOffset = widget.Width / 2 + 20;
TextWidget widget = CreateTextWidget( 0, startY, text, Docking.LeftOrTop, Docking.LeftOrTop, 14, FontStyle.Bold );
widget.XOffset = leftEnd + 30;
widget.MoveTo( widget.X + widget.XOffset, widget.Y );
keysRight[i] = widget;
keysRight[i] = new KeyMapWidget( widget, mappings[i], descriptions[i] );
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 );
widget.Style = style;
widget.Init();
widget.HorizontalDocking = Docking.Centre;
widget.HorizontalDocking = horizontal;
widget.VerticalDocking = vertical;
widget.XOffset = x;
widget.YOffset = y;
@ -99,6 +104,7 @@ namespace ClassicalSharp {
gameWidget.OnResize( oldWidth, oldHeight, width, height );
controlsWidget.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++ ) {
keysLeft[i].OnResize( oldWidth, oldHeight, width, height );
}
@ -111,6 +117,49 @@ namespace ClassicalSharp {
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 ) {
if( button != MouseButton.Left ) return false;
if( exitWidget.ContainsPoint( mouseX, mouseY ) ) {
@ -119,8 +168,59 @@ namespace ClassicalSharp {
} else if( gameWidget.ContainsPoint( mouseX, mouseY ) ) {
Window.SetNewScreen( new NormalScreen( Window ) );
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;
}
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();
}
}
}
}

View File

@ -1,184 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Exe</OutputType>
<RootNamespace>ClassicalSharp</RootNamespace>
<AssemblyName>ClassicalSharp</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<RunCodeAnalysis>False</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>output\debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Project</StartAction>
<StartArguments>wwwf null 127.0.0.1 25566</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>output\release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="2D\DrawTextArgs.cs" />
<Compile Include="2D\Screens\BlockSelectScreen.cs" />
<Compile Include="2D\Screens\ChatScreen.cs" />
<Compile Include="2D\Screens\ErrorScreen.cs" />
<Compile Include="2D\Screens\FpsScreen.cs" />
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
<Compile Include="2D\Screens\NormalScreen.cs" />
<Compile Include="2D\Screens\PauseScreen.cs" />
<Compile Include="2D\Screens\Screen.cs" />
<Compile Include="2D\Utils2D.cs" />
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
<Compile Include="2D\Widgets\ExtPlayerListWidget.cs" />
<Compile Include="2D\Widgets\PlayerListWidget.cs" />
<Compile Include="2D\Widgets\TextGroupWidget.cs" />
<Compile Include="2D\Widgets\TextInputWidget.cs" />
<Compile Include="2D\Widgets\TextWidget.cs" />
<Compile Include="2D\Widgets\Widget.cs" />
<Compile Include="Blocks\Block.cs" />
<Compile Include="Blocks\BlockInfo.cs" />
<Compile Include="Blocks\BlockInfo.Optimised.cs" />
<Compile Include="Entities\Entity.cs" />
<Compile Include="Entities\LocalPlayer.cs" />
<Compile Include="Entities\ModelPart.cs" />
<Compile Include="Entities\NetPlayer.cs" />
<Compile Include="Entities\Particle.cs" />
<Compile Include="Entities\ParticleManager.cs" />
<Compile Include="Entities\Player.cs" />
<Compile Include="Entities\PlayerModel.cs" />
<Compile Include="Game\Game.Chat.cs" />
<Compile Include="Game\Game.cs" />
<Compile Include="Game\Game.Events.cs" />
<Compile Include="Game\Game.InputHandling.cs" />
<Compile Include="GraphicsAPI\DirectXApi.cs" />
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Commands\Command.cs" />
<Compile Include="Commands\DefaultCommands.cs" />
<Compile Include="FastBitmap.cs" />
<Compile Include="FastColour.cs" />
<Compile Include="GraphicsAPI\VertexFormats.cs" />
<Compile Include="Map.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilder.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilderTex2Col4.cs" />
<Compile Include="Network\Enums.cs" />
<Compile Include="Network\FastNetReader.cs" />
<Compile Include="Network\FixedBufferStream.cs" />
<Compile Include="Network\NetworkProcessor.cs" />
<Compile Include="Network\AsyncDownloader.cs" />
<Compile Include="Network\WomConfigHandler.cs" />
<Compile Include="Commands\CommandManager.cs" />
<Compile Include="Commands\CommandReader.cs" />
<Compile Include="Physics\BoundingBox.cs" />
<Compile Include="Physics\Entity.Physics.cs" />
<Compile Include="Physics\IntersectionUtils.cs" />
<Compile Include="Physics\Picking.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rendering\LegacyEnvRenderer.cs" />
<Compile Include="Rendering\LegacyMapEnvRenderer.cs" />
<Compile Include="Rendering\EnvRenderer.cs" />
<Compile Include="Rendering\LegacyFastEnvRenderer.cs" />
<Compile Include="Rendering\FrustumCulling.cs" />
<Compile Include="Rendering\MapEnvRenderer.cs" />
<Compile Include="Rendering\MapRenderer.cs" />
<Compile Include="Rendering\NormalEnvRenderer.cs" />
<Compile Include="Rendering\PickingRenderer.cs" />
<Compile Include="Rendering\PlayerRenderer.cs" />
<Compile Include="Rendering\NormalMapEnvRenderer.cs" />
<Compile Include="Selections\SelectionBox.cs" />
<Compile Include="Selections\SelectionManager.cs" />
<Compile Include="TextureAtlas2D.cs" />
<Compile Include="TextureAtlas1D.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="2D\Screens" />
<Folder Include="2D\Widgets" />
<Folder Include="Blocks" />
<Folder Include="GraphicsAPI" />
<Folder Include="Entities" />
<Folder Include="MeshBuilders" />
<Folder Include="Game" />
<Folder Include="Physics" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Exe</OutputType>
<RootNamespace>ClassicalSharp</RootNamespace>
<AssemblyName>ClassicalSharp</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<RunCodeAnalysis>False</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>output\debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Project</StartAction>
<StartArguments>wwwf null 127.0.0.1 25566</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>output\release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="2D\DrawTextArgs.cs" />
<Compile Include="2D\Screens\BlockSelectScreen.cs" />
<Compile Include="2D\Screens\ChatScreen.cs" />
<Compile Include="2D\Screens\ErrorScreen.cs" />
<Compile Include="2D\Screens\FpsScreen.cs" />
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
<Compile Include="2D\Screens\NormalScreen.cs" />
<Compile Include="2D\Screens\PauseScreen.cs" />
<Compile Include="2D\Screens\Screen.cs" />
<Compile Include="2D\Utils2D.cs" />
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
<Compile Include="2D\Widgets\ExtPlayerListWidget.cs" />
<Compile Include="2D\Widgets\PlayerListWidget.cs" />
<Compile Include="2D\Widgets\TextGroupWidget.cs" />
<Compile Include="2D\Widgets\TextInputWidget.cs" />
<Compile Include="2D\Widgets\TextWidget.cs" />
<Compile Include="2D\Widgets\Widget.cs" />
<Compile Include="Blocks\Block.cs" />
<Compile Include="Blocks\BlockInfo.cs" />
<Compile Include="Blocks\BlockInfo.Optimised.cs" />
<Compile Include="Entities\Entity.cs" />
<Compile Include="Entities\LocalPlayer.cs" />
<Compile Include="Entities\ModelPart.cs" />
<Compile Include="Entities\NetPlayer.cs" />
<Compile Include="Entities\Particle.cs" />
<Compile Include="Entities\ParticleManager.cs" />
<Compile Include="Entities\Player.cs" />
<Compile Include="Entities\PlayerModel.cs" />
<Compile Include="Game\Game.Chat.cs" />
<Compile Include="Game\Game.cs" />
<Compile Include="Game\Game.Events.cs" />
<Compile Include="Game\Game.InputHandling.cs" />
<Compile Include="GraphicsAPI\DirectXApi.cs" />
<Compile Include="GraphicsAPI\IGraphicsApi.cs" />
<Compile Include="GraphicsAPI\OpenGLApi.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Commands\Command.cs" />
<Compile Include="Commands\DefaultCommands.cs" />
<Compile Include="FastBitmap.cs" />
<Compile Include="FastColour.cs" />
<Compile Include="GraphicsAPI\VertexFormats.cs" />
<Compile Include="Map.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilder.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilderTex2Col4.cs" />
<Compile Include="Network\Enums.cs" />
<Compile Include="Network\FastNetReader.cs" />
<Compile Include="Network\FixedBufferStream.cs" />
<Compile Include="Network\NetworkProcessor.cs" />
<Compile Include="Network\AsyncDownloader.cs" />
<Compile Include="Network\WomConfigHandler.cs" />
<Compile Include="Commands\CommandManager.cs" />
<Compile Include="Commands\CommandReader.cs" />
<Compile Include="Physics\BoundingBox.cs" />
<Compile Include="Physics\Entity.Physics.cs" />
<Compile Include="Physics\IntersectionUtils.cs" />
<Compile Include="Physics\Picking.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rendering\LegacyEnvRenderer.cs" />
<Compile Include="Rendering\LegacyMapEnvRenderer.cs" />
<Compile Include="Rendering\EnvRenderer.cs" />
<Compile Include="Rendering\LegacyFastEnvRenderer.cs" />
<Compile Include="Rendering\FrustumCulling.cs" />
<Compile Include="Rendering\MapEnvRenderer.cs" />
<Compile Include="Rendering\MapRenderer.cs" />
<Compile Include="Rendering\NormalEnvRenderer.cs" />
<Compile Include="Rendering\PickingRenderer.cs" />
<Compile Include="Rendering\PlayerRenderer.cs" />
<Compile Include="Rendering\NormalMapEnvRenderer.cs" />
<Compile Include="Selections\SelectionBox.cs" />
<Compile Include="Selections\SelectionManager.cs" />
<Compile Include="TextureAtlas2D.cs" />
<Compile Include="TextureAtlas1D.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="2D\Screens" />
<Folder Include="2D\Widgets" />
<Folder Include="Blocks" />
<Folder Include="GraphicsAPI" />
<Folder Include="Entities" />
<Folder Include="MeshBuilders" />
<Folder Include="Game" />
<Folder Include="Physics" />
</ItemGroup>
</Project>

View File

@ -79,7 +79,7 @@ namespace ClassicalSharp {
} else if( key == Keys[KeyMapping.Fullscreen] ) {
WindowState state = WindowState;
if( state != WindowState.Minimized ) {
WindowState = state == WindowState.Fullscreen ?
WindowState = state == WindowState.Fullscreen ?
WindowState.Normal : WindowState.Fullscreen;
}
} else if( key == Keys[KeyMapping.ThirdPersonCamera] ) {
@ -147,58 +147,54 @@ namespace ClassicalSharp {
return block == 0 || ( !CanPlace[block] && !CanDelete[block] && BlockInfo.IsLiquid( block ) );
}
public KeyMap Keys = new KeyMap();
public KeyMap Keys = new KeyMap();
}
public class KeyMap {
public Key this[KeyMapping key] {
get { return Keys[(int)key]; }
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 Key this[KeyMapping key] {
get { return Keys[(int)key]; }
set { Keys[(int)key] = value; }
}
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,
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 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,
}
}