diff options
| author | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
|---|---|---|
| committer | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
| commit | 71e94ee161447b84c0eaabf6567f8fa62262cd3e (patch) | |
| tree | 391064cc6173a6fe75069af2fdc1978af12f623e /examples/25.XmlHandling | |
| download | irrlicht-master.tar.gz irrlicht-master.tar.bz2 irrlicht-master.zip | |
Diffstat (limited to 'examples/25.XmlHandling')
| -rw-r--r-- | examples/25.XmlHandling/Makefile | 66 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling.cbp | 55 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling.vcproj | 195 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling_vc10.vcxproj | 182 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling_vc11.vcxproj | 182 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling_vc12.vcxproj | 182 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling_vc8.vcproj | 190 | ||||
| -rw-r--r-- | examples/25.XmlHandling/XmlHandling_vc9.vcproj | 185 | ||||
| -rw-r--r-- | examples/25.XmlHandling/main.cpp | 507 | ||||
| -rw-r--r-- | examples/25.XmlHandling/tutorial.html | 219 |
10 files changed, 1963 insertions, 0 deletions
diff --git a/examples/25.XmlHandling/Makefile b/examples/25.XmlHandling/Makefile new file mode 100644 index 0000000..92f5655 --- /dev/null +++ b/examples/25.XmlHandling/Makefile @@ -0,0 +1,66 @@ +# Makefile for Irrlicht Examples
+# It's usually sufficient to change just the target name and source file list
+# and be sure that CXX is set to a valid compiler
+
+# Name of the executable created (.exe will be added automatically if necessary)
+Target := 25.XmlHandling
+# List of source files, separated by spaces
+Sources := main.cpp
+# Path to Irrlicht directory, should contain include/ and lib/
+IrrlichtHome := ../..
+# Path for the executable. Note that Irrlicht.dll should usually also be there for win32 systems
+BinPath = ../../bin/$(SYSTEM)
+
+# general compiler settings (might need to be set when compiling the lib, too)
+# preprocessor flags, e.g. defines and include paths
+USERCPPFLAGS =
+# compiler flags such as optimization flags
+USERCXXFLAGS = -O3 -ffast-math
+#USERCXXFLAGS = -g -Wall
+# linker flags such as additional libraries and link paths
+USERLDFLAGS =
+
+####
+#no changes necessary below this line
+####
+
+CPPFLAGS = -I$(IrrlichtHome)/include -I/usr/X11R6/include $(USERCPPFLAGS)
+CXXFLAGS = $(USERCXXFLAGS)
+LDFLAGS = $(USERLDFLAGS)
+
+#default target is Linux
+all: all_linux
+
+# target specific settings
+all_linux all_win32 static_win32: LDFLAGS += -L$(IrrlichtHome)/lib/$(SYSTEM) -lIrrlicht
+all_linux: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm -lXext -lX11 -lXcursor
+all_linux clean_linux: SYSTEM=Linux
+all_win32 clean_win32 static_win32: SYSTEM=Win32-gcc
+all_win32 clean_win32 static_win32: SUF=.exe
+static_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
+all_win32: LDFLAGS += -lopengl32 -lm
+static_win32: LDFLAGS += -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32
+# name of the binary - only valid for targets which set SYSTEM
+DESTPATH = $(BinPath)/$(Target)$(SUF)
+
+all_linux all_win32 static_win32:
+ $(warning Building...)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
+
+clean: clean_linux clean_win32
+ $(warning Cleaning...)
+
+clean_linux clean_win32:
+ @$(RM) $(DESTPATH)
+
+.PHONY: all all_win32 static_win32 clean clean_linux clean_win32
+
+#multilib handling
+ifeq ($(HOSTTYPE), x86_64)
+LIBSELECT=64
+endif
+#solaris real-time features
+ifeq ($(HOSTTYPE), sun4)
+LDFLAGS += -lrt
+endif
+
diff --git a/examples/25.XmlHandling/XmlHandling.cbp b/examples/25.XmlHandling/XmlHandling.cbp new file mode 100644 index 0000000..b9bc5c9 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling.cbp @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Irrlicht Example 25 Xml handling" /> + <Option pch_mode="0" /> + <Option compiler="gcc" /> + <Build> + <Target title="Linux"> + <Option platforms="Unix;" /> + <Option output="../../bin/Linux/XmlHandling" prefix_auto="0" extension_auto="0" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + <Add option="-D_IRR_STATIC_LIB_" /> + </Compiler> + <Linker> + <Add library="Xxf86vm" /> + <Add library="X11" /> + <Add library="GL" /> + <Add directory="../../lib/Linux" /> + </Linker> + </Target> + <Target title="Windows"> + <Option platforms="Windows;" /> + <Option output="../../bin/Win32-gcc/XmlHandling" prefix_auto="0" extension_auto="1" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + </Compiler> + <Linker> + <Add directory="../../lib/Win32-gcc" /> + </Linker> + </Target> + </Build> + <VirtualTargets> + <Add alias="All" targets="Windows;Linux;" /> + </VirtualTargets> + <Compiler> + <Add option="-g" /> + <Add directory="../../include" /> + </Compiler> + <Linker> + <Add library="Irrlicht" /> + </Linker> + <Unit filename="main.cpp" /> + <Extensions> + <code_completion /> + <debugger /> + <envvars /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/examples/25.XmlHandling/XmlHandling.vcproj b/examples/25.XmlHandling/XmlHandling.vcproj new file mode 100644 index 0000000..152a415 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling.vcproj @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="25.XmlHandling"
+ ProjectGUID="{8FDA260E-EF27-4f8c-8720-7AF707DD0D9E}"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="_IRR_STATIC_LIB_;WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/XmlHandling.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/QIfist /Oa"
+ Optimization="3"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ OmitFramePointers="true"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="0"
+ CallingConvention="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/25.XmlHandling/XmlHandling_vc10.vcxproj b/examples/25.XmlHandling/XmlHandling_vc10.vcxproj new file mode 100644 index 0000000..43f9e73 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling_vc10.vcxproj @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>25.XmlHandling</ProjectName>
+ <ProjectGuid>{8FDA260E-EF27-4F8C-8720-7AF707DD0D9E}</ProjectGuid>
+ <RootNamespace>25.XmlHandling</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/25.XmlHandling/XmlHandling_vc11.vcxproj b/examples/25.XmlHandling/XmlHandling_vc11.vcxproj new file mode 100644 index 0000000..43f9e73 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling_vc11.vcxproj @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>25.XmlHandling</ProjectName>
+ <ProjectGuid>{8FDA260E-EF27-4F8C-8720-7AF707DD0D9E}</ProjectGuid>
+ <RootNamespace>25.XmlHandling</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/25.XmlHandling/XmlHandling_vc12.vcxproj b/examples/25.XmlHandling/XmlHandling_vc12.vcxproj new file mode 100644 index 0000000..5354637 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling_vc12.vcxproj @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>25.XmlHandling</ProjectName>
+ <ProjectGuid>{8FDA260E-EF27-4F8C-8720-7AF707DD0D9E}</ProjectGuid>
+ <RootNamespace>25.XmlHandling</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\Win32-VisualStudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\bin\Win64-VisualStudio\</OutDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <CallingConvention>Cdecl</CallingConvention>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/examples/25.XmlHandling/XmlHandling_vc8.vcproj b/examples/25.XmlHandling/XmlHandling_vc8.vcproj new file mode 100644 index 0000000..0831ba9 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling_vc8.vcproj @@ -0,0 +1,190 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="25.XmlHandling_vc8"
+ ProjectGUID="{8FDA260E-EF27-4f8c-8720-7AF707DD0D9E}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/XmlHandling.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="0"
+ CallingConvention="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/25.XmlHandling/XmlHandling_vc9.vcproj b/examples/25.XmlHandling/XmlHandling_vc9.vcproj new file mode 100644 index 0000000..79a1048 --- /dev/null +++ b/examples/25.XmlHandling/XmlHandling_vc9.vcproj @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="25.XmlHandling_vc9"
+ ProjectGUID="{8FDA260E-EF27-4F8C-8720-7AF707DD0D9E}"
+ RootNamespace="25.XmlHandling_vc9"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/XmlHandling.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ ExceptionHandling="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="0"
+ CallingConvention="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="..\..\bin\Win32-VisualStudio\25.XmlHandling.exe"
+ AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
+ GenerateDebugInformation="false"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/examples/25.XmlHandling/main.cpp b/examples/25.XmlHandling/main.cpp new file mode 100644 index 0000000..25e813c --- /dev/null +++ b/examples/25.XmlHandling/main.cpp @@ -0,0 +1,507 @@ +/** Example 025 Xml Handling
+
+Demonstrates loading and saving of configurations via XML
+
+@author Y.M. Bosman \<yoran.bosman@gmail.com\>
+
+This demo features a fully usable system for configuration handling. The code
+can easily be integrated into own apps.
+
+*/
+
+#include <irrlicht.h>
+
+using namespace irr;
+using namespace core;
+using namespace scene;
+using namespace video;
+using namespace io;
+using namespace gui;
+
+#ifdef _IRR_WINDOWS_
+#pragma comment(lib, "Irrlicht.lib")
+#endif
+
+
+/* SettingManager class.
+
+This class loads and writes the settings and manages the options.
+
+The class makes use of irrMap which is a an associative arrays using a
+red-black tree it allows easy mapping of a key to a value, along the way there
+is some information on how to use it.
+*/
+
+class SettingManager
+{
+public:
+
+ // Construct setting managers and set default settings
+ SettingManager(const stringw& settings_file): SettingsFile(settings_file), NullDevice(0)
+ {
+ // Irrlicht null device, we want to load settings before we actually created our device, therefore, nulldevice
+ NullDevice = irr::createDevice(irr::video::EDT_NULL);
+
+ //DriverOptions is an irrlicht map,
+ //we can insert values in the map in two ways by calling insert(key,value) or by using the [key] operator
+ //the [] operator overrides values if they already exist
+ DriverOptions.insert(L"Software", EDT_SOFTWARE);
+ DriverOptions.insert(L"OpenGL", EDT_OPENGL);
+ DriverOptions.insert(L"Direct3D9", EDT_DIRECT3D9);
+
+ //some resolution options
+ ResolutionOptions.insert(L"640x480", dimension2du(640,480));
+ ResolutionOptions.insert(L"800x600", dimension2du(800,600));
+ ResolutionOptions.insert(L"1024x768", dimension2du(1024,768));
+
+ //our preferred defaults
+ SettingMap.insert(L"driver", L"Direct3D9");
+ SettingMap.insert(L"resolution", L"640x480");
+ SettingMap.insert(L"fullscreen", L"0"); //0 is false
+ }
+
+ // Destructor, you could store settings automatically on exit of your
+ // application if you wanted to in our case we simply drop the
+ // nulldevice
+ ~SettingManager()
+ {
+ if (NullDevice)
+ {
+ NullDevice->closeDevice();
+ NullDevice->drop();
+ }
+ };
+
+ /*
+ Load xml from disk, overwrite default settings
+ The xml we are trying to load has the following structure
+ settings nested in sections nested in the root node, like:
+ \verbatim
+ <pre>
+ <?xml version="1.0"?>
+ <mygame>
+ <video>
+ <setting name="driver" value="Direct3D9" />
+ <setting name="fullscreen" value="0" />
+ <setting name="resolution" value="1024x768" />
+ </video>
+ </mygame>
+ </pre>
+ \endverbatim
+ */
+ bool load()
+ {
+ //if not able to create device don't attempt to load
+ if (!NullDevice)
+ return false;
+
+ irr::io::IXMLReader* xml = NullDevice->getFileSystem()->createXMLReader(SettingsFile); //create xml reader
+ if (!xml)
+ return false;
+
+ const stringw settingTag(L"setting"); //we'll be looking for this tag in the xml
+ stringw currentSection; //keep track of our current section
+ const stringw videoTag(L"video"); //constant for videotag
+
+ //while there is more to read
+ while (xml->read())
+ {
+ //check the node type
+ switch (xml->getNodeType())
+ {
+ //we found a new element
+ case irr::io::EXN_ELEMENT:
+ {
+ //we currently are in the empty or mygame section and find the video tag so we set our current section to video
+ if (currentSection.empty() && videoTag.equals_ignore_case(xml->getNodeName()))
+ {
+ currentSection = videoTag;
+ }
+ //we are in the video section and we find a setting to parse
+ else if (currentSection.equals_ignore_case(videoTag) && settingTag.equals_ignore_case(xml->getNodeName() ))
+ {
+ //read in the key
+ stringw key = xml->getAttributeValueSafe(L"name");
+ //if there actually is a key to set
+ if (!key.empty())
+ {
+ //set the setting in the map to the value,
+ //the [] operator overrides values if they already exist or inserts a new key value
+ //pair into the settings map if it was not defined yet
+ SettingMap[key] = xml->getAttributeValueSafe(L"value");
+ }
+ }
+
+ //..
+ // You can add your own sections and tags to read in here
+ //..
+ }
+ break;
+
+ //we found the end of an element
+ case irr::io::EXN_ELEMENT_END:
+ //we were at the end of the video section so we reset our tag
+ currentSection=L"";
+ break;
+ }
+ }
+
+ // don't forget to delete the xml reader
+ xml->drop();
+
+ return true;
+ }
+
+ // Save the xml to disk. We use the nulldevice.
+ bool save()
+ {
+
+ //if not able to create device don't attempt to save
+ if (!NullDevice)
+ return false;
+
+ //create xml writer
+ irr::io::IXMLWriter* xwriter = NullDevice->getFileSystem()->createXMLWriter( SettingsFile );
+ if (!xwriter)
+ return false;
+
+ //write out the obligatory xml header. Each xml-file needs to have exactly one of those.
+ xwriter->writeXMLHeader();
+
+ //start element mygame, you replace the label "mygame" with anything you want
+ xwriter->writeElement(L"mygame");
+ xwriter->writeLineBreak(); //new line
+
+ //start section with video settings
+ xwriter->writeElement(L"video");
+ xwriter->writeLineBreak(); //new line
+
+ // getIterator gets us a pointer to the first node of the settings map
+ // every iteration we increase the iterator which gives us the next map node
+ // until we reach the end we write settings one by one by using the nodes key and value functions
+ map<stringw, stringw>::Iterator i = SettingMap.getIterator();
+ for(; !i.atEnd(); i++)
+ {
+ //write element as <setting name="key" value="x" />
+ //the second parameter indicates this is an empty element with no children, just attributes
+ xwriter->writeElement(L"setting",true, L"name", i->getKey().c_str(), L"value",i->getValue().c_str() );
+ xwriter->writeLineBreak();
+ }
+ xwriter->writeLineBreak();
+
+ //close video section
+ xwriter->writeClosingTag(L"video");
+ xwriter->writeLineBreak();
+
+ //..
+ // You can add writing sound settings, savegame information etc
+ //..
+
+ //close mygame section
+ xwriter->writeClosingTag(L"mygame");
+
+ //delete xml writer
+ xwriter->drop();
+
+ return true;
+ }
+
+ // Set setting in our manager
+ void setSetting(const stringw& name, const stringw& value)
+ {
+ SettingMap[name]=value;
+ }
+
+ // set setting overload to quickly assign integers to our setting map
+ void setSetting(const stringw& name, s32 value)
+ {
+ SettingMap[name]=stringw(value);
+ }
+
+ // Get setting as string
+ stringw getSetting(const stringw& key) const
+ {
+ //the find function or irrmap returns a pointer to a map Node
+ //if the key can be found, otherwise it returns null
+ //the map node has the function getValue and getKey, as we already know the key, we return node->getValue()
+ map<stringw, stringw>::Node* n = SettingMap.find(key);
+ if (n)
+ return n->getValue();
+ else
+ return L"";
+ }
+
+ //
+ bool getSettingAsBoolean(const stringw& key ) const
+ {
+ stringw s = getSetting(key);
+ if (s.empty())
+ return false;
+ return s.equals_ignore_case(L"1");
+ }
+
+ //
+ s32 getSettingAsInteger(const stringw& key) const
+ {
+ //we implicitly cast to string instead of stringw because strtol10 does not accept wide strings
+ const stringc s = getSetting(key);
+ if (s.empty())
+ return 0;
+
+ return strtol10(s.c_str());
+ }
+
+public:
+ map<stringw, s32> DriverOptions; //available options for driver config
+ map<stringw, dimension2du> ResolutionOptions; //available options for resolution config
+private:
+ SettingManager(const SettingManager& other); // defined but not implemented
+ SettingManager& operator=(const SettingManager& other); // defined but not implemented
+
+ map<stringw, stringw> SettingMap; //current config
+
+ stringw SettingsFile; // location of the xml, usually the
+ irr::IrrlichtDevice* NullDevice;
+};
+
+/*
+Application context for global variables
+*/
+struct SAppContext
+{
+ SAppContext()
+ : Device(0),Gui(0), Driver(0), Settings(0), ShouldQuit(false),
+ ButtonSave(0), ButtonExit(0), ListboxDriver(0),
+ ListboxResolution(0), CheckboxFullscreen(0)
+ {
+ }
+
+ ~SAppContext()
+ {
+ if (Settings)
+ delete Settings;
+
+ if (Device)
+ {
+ Device->closeDevice();
+ Device->drop();
+ }
+ }
+
+ IrrlichtDevice* Device;
+ IGUIEnvironment* Gui;
+ IVideoDriver* Driver;
+ SettingManager* Settings;
+ bool ShouldQuit;
+
+ //settings dialog
+ IGUIButton* ButtonSave;
+ IGUIButton* ButtonExit;
+ IGUIListBox* ListboxDriver;
+ IGUIListBox* ListboxResolution;
+ IGUICheckBox* CheckboxFullscreen;
+};
+
+/*
+ A typical event receiver.
+*/
+class MyEventReceiver : public IEventReceiver
+{
+public:
+ MyEventReceiver(SAppContext & a) : App(a) { }
+
+ virtual bool OnEvent(const SEvent& event)
+ {
+ if (event.EventType == EET_GUI_EVENT )
+ {
+ switch ( event.GUIEvent.EventType )
+ {
+ //handle button click events
+ case EGET_BUTTON_CLICKED:
+ {
+ //Our save button was called so we obtain the settings from our dialog and save them
+ if ( event.GUIEvent.Caller == App.ButtonSave )
+ {
+ //if there is a selection write it
+ if ( App.ListboxDriver->getSelected() != -1)
+ App.Settings->setSetting(L"driver", App.ListboxDriver->getListItem(App.ListboxDriver->getSelected()));
+
+ //if there is a selection write it
+ if ( App.ListboxResolution->getSelected() != -1)
+ App.Settings->setSetting(L"resolution", App.ListboxResolution->getListItem(App.ListboxResolution->getSelected()));
+
+ App.Settings->setSetting(L"fullscreen", App.CheckboxFullscreen->isChecked());
+
+
+ if (App.Settings->save())
+ {
+ App.Gui->addMessageBox(L"settings save",L"settings saved, please restart for settings to change effect","",true);
+ }
+ }
+ // cancel/exit button clicked, tell the application to exit
+ else if ( event.GUIEvent.Caller == App.ButtonExit)
+ {
+ App.ShouldQuit = true;
+ }
+ }
+ break;
+ }
+ }
+
+ return false;
+ }
+
+private:
+ SAppContext & App;
+};
+
+
+/*
+Function to create a video settings dialog
+This dialog shows the current settings from the configuration xml and allows them to be changed
+*/
+void createSettingsDialog(SAppContext& app)
+{
+ // first get rid of alpha in gui
+ for (irr::s32 i=0; i<irr::gui::EGDC_COUNT ; ++i)
+ {
+ irr::video::SColor col = app.Gui->getSkin()->getColor((irr::gui::EGUI_DEFAULT_COLOR)i);
+ col.setAlpha(255);
+ app.Gui->getSkin()->setColor((irr::gui::EGUI_DEFAULT_COLOR)i, col);
+ }
+
+ //create video settings windows
+ gui::IGUIWindow* windowSettings = app.Gui->addWindow(rect<s32>(10,10,400,400),true,L"Videosettings");
+ app.Gui->addStaticText (L"Select your desired video settings", rect< s32 >(10,20, 200, 40), false, true, windowSettings);
+
+ // add listbox for driver choice
+ app.Gui->addStaticText (L"Driver", rect< s32 >(10,50, 200, 60), false, true, windowSettings);
+ app.ListboxDriver = app.Gui->addListBox(rect<s32>(10,60,220,120), windowSettings, 1,true);
+
+ //add all available options to the driver choice listbox
+ map<stringw, s32>::Iterator i = app.Settings->DriverOptions.getIterator();
+ for(; !i.atEnd(); i++)
+ app.ListboxDriver->addItem(i->getKey().c_str());
+
+ //set currently selected driver
+ app.ListboxDriver->setSelected(app.Settings->getSetting("driver").c_str());
+
+ // add listbox for resolution choice
+ app.Gui->addStaticText (L"Resolution", rect< s32 >(10,130, 200, 140), false, true, windowSettings);
+ app.ListboxResolution = app.Gui->addListBox(rect<s32>(10,140,220,200), windowSettings, 1,true);
+
+ //add all available options to the resolution listbox
+ map<stringw, dimension2du>::Iterator ri = app.Settings->ResolutionOptions.getIterator();
+ for(; !ri.atEnd(); ri++)
+ app.ListboxResolution->addItem(ri->getKey().c_str());
+
+ //set currently selected resolution
+ app.ListboxResolution->setSelected(app.Settings->getSetting("resolution").c_str());
+
+ //add checkbox to toggle fullscreen, initially set to loaded setting
+ app.CheckboxFullscreen = app.Gui->addCheckBox(
+ app.Settings->getSettingAsBoolean("fullscreen"),
+ rect<s32>(10,220,220,240), windowSettings, -1,
+ L"Fullscreen");
+
+ //last but not least add save button
+ app.ButtonSave = app.Gui->addButton(
+ rect<s32>(80,250,150,270), windowSettings, 2,
+ L"Save video settings");
+
+ //exit/cancel button
+ app.ButtonExit = app.Gui->addButton(
+ rect<s32>(160,250,240,270), windowSettings, 2,
+ L"Cancel and exit");
+}
+
+/*
+The main function. Creates all objects and does the XML handling.
+*/
+int main()
+{
+ //create new application context
+ SAppContext app;
+
+ //create device creation parameters that can get overwritten by our settings file
+ SIrrlichtCreationParameters param;
+ param.DriverType = EDT_SOFTWARE;
+ param.WindowSize.set(640,480);
+
+ // Try to load config.
+ // I leave it as an exercise of the reader to store the configuration in the local application data folder,
+ // the only logical place to store config data for games. For all other operating systems I redirect to your manuals
+ app.Settings = new SettingManager("../../media/settings.xml");
+ if ( !app.Settings->load() )
+ {
+ // ...
+ // Here add your own exception handling, for now we continue because there are defaults set in SettingManager constructor
+ // ...
+ }
+ else
+ {
+ //settings xml loaded from disk,
+
+ //map driversetting to driver type and test if the setting is valid
+ //the DriverOptions map contains string representations mapped to to irrlicht E_DRIVER_TYPE enum
+ //e.g "direct3d9" will become 4
+ //see DriverOptions in the settingmanager class for details
+ map<stringw, s32>::Node* driver = app.Settings->DriverOptions.find( app.Settings->getSetting("driver") );
+
+ if (driver)
+ {
+ if ( irr::IrrlichtDevice::isDriverSupported( static_cast<E_DRIVER_TYPE>( driver->getValue() )))
+ {
+ // selected driver is supported, so we use it.
+ param.DriverType = static_cast<E_DRIVER_TYPE>( driver->getValue());
+ }
+ }
+
+ //map resolution setting to dimension in a similar way as demonstrated above
+ map<stringw, dimension2du>::Node* res = app.Settings->ResolutionOptions.find( app.Settings->getSetting("resolution") );
+ if (res)
+ {
+ param.WindowSize = res->getValue();
+ }
+
+ //get fullscreen setting from config
+ param.Fullscreen = app.Settings->getSettingAsBoolean("fullscreen");
+ }
+
+ //create the irrlicht device using the settings
+ app.Device = createDeviceEx(param);
+ if (app.Device == 0)
+ {
+ // You can add your own exception handling on driver failure
+ exit(0);
+ }
+
+ app.Device->setWindowCaption(L"Xmlhandling - Irrlicht engine tutorial");
+ app.Driver = app.Device->getVideoDriver();
+ app.Gui = app.Device->getGUIEnvironment();
+
+ createSettingsDialog(app);
+
+ //set event receiver so we can respond to gui events
+ MyEventReceiver receiver(app);
+ app.Device->setEventReceiver(&receiver);
+
+ //enter main loop
+ while (!app.ShouldQuit && app.Device->run())
+ {
+ if (app.Device->isWindowActive())
+ {
+ app.Driver->beginScene(true, true, SColor(0,200,200,200));
+ app.Gui->drawAll();
+ app.Driver->endScene();
+ }
+ app.Device->sleep(10);
+ }
+
+ //app destroys device in destructor
+
+ return 0;
+}
+
+/*
+**/
diff --git a/examples/25.XmlHandling/tutorial.html b/examples/25.XmlHandling/tutorial.html new file mode 100644 index 0000000..d5d28a8 --- /dev/null +++ b/examples/25.XmlHandling/tutorial.html @@ -0,0 +1,219 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> +<meta http-equiv="X-UA-Compatible" content="IE=9"/> +<meta name="generator" content="Doxygen 1.8.13"/> +<meta name="viewport" content="width=device-width, initial-scale=1"/> +<title>Tutorial 25: Xml Handling</title> +<html xmlns="http://www.w3.org/1999/xhtml"> +<!-- Wanted to avoid copying .css to each folder, so copied default .css from doxyen in here, kicked out most stuff we don't need for examples and modified some a little bit. + Target was having a single html in each example folder which is created from the main.cpp files and needs no files besides some images below media folder. + Feel free to improve :) + --> +<style> +body, table, div, p, dl { + font: 400 14px/22px; +} +body { + background-color: #F0F0F0; + color: black; + margin-left: 5%; + margin-right: 5%; +} +p.reference, p.definition { + font: 400 14px/22px; +} +.title { + font: 400 14px/28px; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} +caption { + font-weight: bold; +} +h3.version { + font-size: 90%; + text-align: center; +} +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} +.contents a:visited { + color: #4665A2; +} +a:hover { + text-decoration: underline; +} +a.el { + font-weight: bold; +} +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} +div.fragment { + padding: 0px; + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} +div.center img { + border: 0px; +} +span.keyword { + color: #008000 +} +span.keywordtype { + color: #604020 +} +span.keywordflow { + color: #e08000 +} +span.comment { + color: #800000 +} +span.preprocessor { + color: #806020 +} +span.stringliteral { + color: #002080 +} +span.charliteral { + color: #008080 +} +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} +address { + font-style: normal; + color: #2A3D61; +} +div.header { + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} +div.headertitle { + padding: 5px 5px 5px 10px; +} +.image { + text-align: center; +} +.caption { + font-weight: bold; +} +div.zoom { + border: 1px solid #90A5CE; +} +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} +</style> +</head> +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> +<!--END TITLEAREA--> +<!-- end header part --> +<!-- Generated by Doxygen 1.8.13 --> +</div><!-- top --> +<div class="header"> + <div class="headertitle"> +<div class="title">Tutorial 25: Xml Handling </div> </div> +</div><!--header--> +<div class="contents"> +<div class="textblock"><div class="image"> +<img src="../../media/025shot.jpg" alt="025shot.jpg"/> +</div> + <p>Demonstrates loading and saving of configurations via XML</p> +<dl class="section author"><dt>Author</dt><dd>Y.M. Bosman <<a href="#" onclick="location.href='mai'+'lto:'+'yor'+'an'+'.bo'+'sm'+'an@'+'gm'+'ail'+'.c'+'om'; return false;">yoran<span style="display: none;">.nosp@m.</span>.bos<span style="display: none;">.nosp@m.</span>man@g<span style="display: none;">.nosp@m.</span>mail<span style="display: none;">.nosp@m.</span>.com</a>></dd></dl> +<p>This demo features a fully usable system for configuration handling. The code can easily be integrated into own apps.</p> +<div class="fragment"><div class="line"><span class="preprocessor">#include <irrlicht.h></span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span>irr;</div><div class="line"><span class="keyword">using namespace </span>core;</div><div class="line"><span class="keyword">using namespace </span>scene;</div><div class="line"><span class="keyword">using namespace </span>video;</div><div class="line"><span class="keyword">using namespace </span>io;</div><div class="line"><span class="keyword">using namespace </span>gui;</div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef _IRR_WINDOWS_</span></div><div class="line"><span class="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span></div><div class="line"><span class="preprocessor">#endif</span></div></div><!-- fragment --><p> SettingManager class.</p> +<p>This class loads and writes the settings and manages the options.</p> +<p>The class makes use of irrMap which is a an associative arrays using a red-black tree it allows easy mapping of a key to a value, along the way there is some information on how to use it. </p><div class="fragment"><div class="line"><span class="keyword">class </span>SettingManager</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"></div><div class="line"> <span class="comment">// Construct setting managers and set default settings</span></div><div class="line"> SettingManager(<span class="keyword">const</span> stringw& settings_file): SettingsFile(settings_file), NullDevice(0)</div><div class="line"> {</div><div class="line"> <span class="comment">// Irrlicht null device, we want to load settings before we actually created our device, therefore, nulldevice</span></div><div class="line"> NullDevice = irr::createDevice(irr::video::EDT_NULL);</div><div class="line"></div><div class="line"> <span class="comment">//DriverOptions is an irrlicht map,</span></div><div class="line"> <span class="comment">//we can insert values in the map in two ways by calling insert(key,value) or by using the [key] operator</span></div><div class="line"> <span class="comment">//the [] operator overrides values if they already exist</span></div><div class="line"> DriverOptions.insert(L<span class="stringliteral">"Software"</span>, EDT_SOFTWARE);</div><div class="line"> DriverOptions.insert(L<span class="stringliteral">"OpenGL"</span>, EDT_OPENGL);</div><div class="line"> DriverOptions.insert(L<span class="stringliteral">"Direct3D9"</span>, EDT_DIRECT3D9);</div><div class="line"></div><div class="line"> <span class="comment">//some resolution options</span></div><div class="line"> ResolutionOptions.insert(L<span class="stringliteral">"640x480"</span>, dimension2du(640,480));</div><div class="line"> ResolutionOptions.insert(L<span class="stringliteral">"800x600"</span>, dimension2du(800,600));</div><div class="line"> ResolutionOptions.insert(L<span class="stringliteral">"1024x768"</span>, dimension2du(1024,768));</div><div class="line"></div><div class="line"> <span class="comment">//our preferred defaults</span></div><div class="line"> SettingMap.insert(L<span class="stringliteral">"driver"</span>, L<span class="stringliteral">"Direct3D9"</span>);</div><div class="line"> SettingMap.insert(L<span class="stringliteral">"resolution"</span>, L<span class="stringliteral">"640x480"</span>);</div><div class="line"> SettingMap.insert(L<span class="stringliteral">"fullscreen"</span>, L<span class="stringliteral">"0"</span>); <span class="comment">//0 is false</span></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Destructor, you could store settings automatically on exit of your</span></div><div class="line"> <span class="comment">// application if you wanted to in our case we simply drop the</span></div><div class="line"> <span class="comment">// nulldevice</span></div><div class="line"> ~SettingManager()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (NullDevice)</div><div class="line"> {</div><div class="line"> NullDevice->closeDevice();</div><div class="line"> NullDevice->drop();</div><div class="line"> }</div><div class="line"> };</div></div><!-- fragment --><p> Load xml from disk, overwrite default settings The xml we are trying to load has the following structure settings nested in sections nested in the root node, like: </p><pre class="fragment"> <pre> + <?xml version="1.0"?> + <mygame> + <video> + <setting name="driver" value="Direct3D9" /> + <setting name="fullscreen" value="0" /> + <setting name="resolution" value="1024x768" /> + </video> + </mygame> + </pre></pre> <div class="fragment"><div class="line"> <span class="keywordtype">bool</span> load()</div><div class="line"> {</div><div class="line"> <span class="comment">//if not able to create device don't attempt to load</span></div><div class="line"> <span class="keywordflow">if</span> (!NullDevice)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> irr::io::IXMLReader* xml = NullDevice->getFileSystem()->createXMLReader(SettingsFile); <span class="comment">//create xml reader</span></div><div class="line"> <span class="keywordflow">if</span> (!xml)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="keyword">const</span> stringw settingTag(L<span class="stringliteral">"setting"</span>); <span class="comment">//we'll be looking for this tag in the xml</span></div><div class="line"> stringw currentSection; <span class="comment">//keep track of our current section</span></div><div class="line"> <span class="keyword">const</span> stringw videoTag(L<span class="stringliteral">"video"</span>); <span class="comment">//constant for videotag</span></div><div class="line"></div><div class="line"> <span class="comment">//while there is more to read</span></div><div class="line"> <span class="keywordflow">while</span> (xml->read())</div><div class="line"> {</div><div class="line"> <span class="comment">//check the node type</span></div><div class="line"> <span class="keywordflow">switch</span> (xml->getNodeType())</div><div class="line"> {</div><div class="line"> <span class="comment">//we found a new element</span></div><div class="line"> <span class="keywordflow">case</span> irr::io::EXN_ELEMENT:</div><div class="line"> {</div><div class="line"> <span class="comment">//we currently are in the empty or mygame section and find the video tag so we set our current section to video</span></div><div class="line"> <span class="keywordflow">if</span> (currentSection.empty() && videoTag.equals_ignore_case(xml->getNodeName()))</div><div class="line"> {</div><div class="line"> currentSection = videoTag;</div><div class="line"> }</div><div class="line"> <span class="comment">//we are in the video section and we find a setting to parse</span></div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (currentSection.equals_ignore_case(videoTag) && settingTag.equals_ignore_case(xml->getNodeName() ))</div><div class="line"> {</div><div class="line"> <span class="comment">//read in the key</span></div><div class="line"> stringw key = xml->getAttributeValueSafe(L<span class="stringliteral">"name"</span>);</div><div class="line"> <span class="comment">//if there actually is a key to set</span></div><div class="line"> <span class="keywordflow">if</span> (!key.empty())</div><div class="line"> {</div><div class="line"> <span class="comment">//set the setting in the map to the value,</span></div><div class="line"> <span class="comment">//the [] operator overrides values if they already exist or inserts a new key value</span></div><div class="line"> <span class="comment">//pair into the settings map if it was not defined yet</span></div><div class="line"> SettingMap[key] = xml->getAttributeValueSafe(L<span class="stringliteral">"value"</span>);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//..</span></div><div class="line"> <span class="comment">// You can add your own sections and tags to read in here</span></div><div class="line"> <span class="comment">//..</span></div><div class="line"> }</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line"> <span class="comment">//we found the end of an element</span></div><div class="line"> <span class="keywordflow">case</span> irr::io::EXN_ELEMENT_END:</div><div class="line"> <span class="comment">//we were at the end of the video section so we reset our tag</span></div><div class="line"> currentSection=L<span class="stringliteral">""</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// don't forget to delete the xml reader</span></div><div class="line"> xml->drop();</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Save the xml to disk. We use the nulldevice.</span></div><div class="line"> <span class="keywordtype">bool</span> save()</div><div class="line"> {</div><div class="line"></div><div class="line"> <span class="comment">//if not able to create device don't attempt to save</span></div><div class="line"> <span class="keywordflow">if</span> (!NullDevice)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="comment">//create xml writer</span></div><div class="line"> irr::io::IXMLWriter* xwriter = NullDevice->getFileSystem()->createXMLWriter( SettingsFile );</div><div class="line"> <span class="keywordflow">if</span> (!xwriter)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="comment">//write out the obligatory xml header. Each xml-file needs to have exactly one of those.</span></div><div class="line"> xwriter->writeXMLHeader();</div><div class="line"></div><div class="line"> <span class="comment">//start element mygame, you replace the label "mygame" with anything you want</span></div><div class="line"> xwriter->writeElement(L<span class="stringliteral">"mygame"</span>);</div><div class="line"> xwriter->writeLineBreak(); <span class="comment">//new line</span></div><div class="line"></div><div class="line"> <span class="comment">//start section with video settings</span></div><div class="line"> xwriter->writeElement(L<span class="stringliteral">"video"</span>);</div><div class="line"> xwriter->writeLineBreak(); <span class="comment">//new line</span></div><div class="line"></div><div class="line"> <span class="comment">// getIterator gets us a pointer to the first node of the settings map</span></div><div class="line"> <span class="comment">// every iteration we increase the iterator which gives us the next map node</span></div><div class="line"> <span class="comment">// until we reach the end we write settings one by one by using the nodes key and value functions</span></div><div class="line"> map<stringw, stringw>::Iterator i = SettingMap.getIterator();</div><div class="line"> <span class="keywordflow">for</span>(; !i.atEnd(); i++)</div><div class="line"> {</div><div class="line"> <span class="comment">//write element as <setting name="key" value="x" /></span></div><div class="line"> <span class="comment">//the second parameter indicates this is an empty element with no children, just attributes</span></div><div class="line"> xwriter->writeElement(L<span class="stringliteral">"setting"</span>,<span class="keyword">true</span>, L<span class="stringliteral">"name"</span>, i->getKey().c_str(), L<span class="stringliteral">"value"</span>,i->getValue().c_str() );</div><div class="line"> xwriter->writeLineBreak();</div><div class="line"> }</div><div class="line"> xwriter->writeLineBreak();</div><div class="line"></div><div class="line"> <span class="comment">//close video section</span></div><div class="line"> xwriter->writeClosingTag(L<span class="stringliteral">"video"</span>);</div><div class="line"> xwriter->writeLineBreak();</div><div class="line"></div><div class="line"> <span class="comment">//..</span></div><div class="line"> <span class="comment">// You can add writing sound settings, savegame information etc</span></div><div class="line"> <span class="comment">//..</span></div><div class="line"></div><div class="line"> <span class="comment">//close mygame section</span></div><div class="line"> xwriter->writeClosingTag(L<span class="stringliteral">"mygame"</span>);</div><div class="line"></div><div class="line"> <span class="comment">//delete xml writer</span></div><div class="line"> xwriter->drop();</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Set setting in our manager</span></div><div class="line"> <span class="keywordtype">void</span> setSetting(<span class="keyword">const</span> stringw& name, <span class="keyword">const</span> stringw& value)</div><div class="line"> {</div><div class="line"> SettingMap[name]=value;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// set setting overload to quickly assign integers to our setting map</span></div><div class="line"> <span class="keywordtype">void</span> setSetting(<span class="keyword">const</span> stringw& name, s32 value)</div><div class="line"> {</div><div class="line"> SettingMap[name]=stringw(value);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Get setting as string</span></div><div class="line"> stringw getSetting(<span class="keyword">const</span> stringw& key)<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> <span class="comment">//the find function or irrmap returns a pointer to a map Node</span></div><div class="line"> <span class="comment">//if the key can be found, otherwise it returns null</span></div><div class="line"> <span class="comment">//the map node has the function getValue and getKey, as we already know the key, we return node->getValue()</span></div><div class="line"> map<stringw, stringw>::Node* n = SettingMap.find(key);</div><div class="line"> <span class="keywordflow">if</span> (n)</div><div class="line"> <span class="keywordflow">return</span> n->getValue();</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">return</span> L<span class="stringliteral">""</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//</span></div><div class="line"> <span class="keywordtype">bool</span> getSettingAsBoolean(<span class="keyword">const</span> stringw& key )<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> stringw s = getSetting(key);</div><div class="line"> <span class="keywordflow">if</span> (s.empty())</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> <span class="keywordflow">return</span> s.equals_ignore_case(L<span class="stringliteral">"1"</span>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//</span></div><div class="line"> s32 getSettingAsInteger(<span class="keyword">const</span> stringw& key)<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> <span class="comment">//we implicitly cast to string instead of stringw because strtol10 does not accept wide strings</span></div><div class="line"> <span class="keyword">const</span> stringc s = getSetting(key);</div><div class="line"> <span class="keywordflow">if</span> (s.empty())</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> strtol10(s.c_str());</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">public</span>:</div><div class="line"> map<stringw, s32> DriverOptions; <span class="comment">//available options for driver config</span></div><div class="line"> map<stringw, dimension2du> ResolutionOptions; <span class="comment">//available options for resolution config</span></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> SettingManager(<span class="keyword">const</span> SettingManager& other); <span class="comment">// defined but not implemented</span></div><div class="line"> SettingManager& operator=(<span class="keyword">const</span> SettingManager& other); <span class="comment">// defined but not implemented</span></div><div class="line"></div><div class="line"> map<stringw, stringw> SettingMap; <span class="comment">//current config</span></div><div class="line"></div><div class="line"> stringw SettingsFile; <span class="comment">// location of the xml, usually the</span></div><div class="line"> irr::IrrlichtDevice* NullDevice;</div><div class="line">};</div></div><!-- fragment --><p> Application context for global variables </p><div class="fragment"><div class="line"><span class="keyword">struct </span>SAppContext</div><div class="line">{</div><div class="line"> SAppContext()</div><div class="line"> : Device(0),Gui(0), Driver(0), Settings(0), ShouldQuit(false),</div><div class="line"> ButtonSave(0), ButtonExit(0), ListboxDriver(0),</div><div class="line"> ListboxResolution(0), CheckboxFullscreen(0)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> ~SAppContext()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (Settings)</div><div class="line"> <span class="keyword">delete</span> Settings;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (Device)</div><div class="line"> {</div><div class="line"> Device->closeDevice();</div><div class="line"> Device->drop();</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> IrrlichtDevice* Device;</div><div class="line"> IGUIEnvironment* Gui;</div><div class="line"> IVideoDriver* Driver;</div><div class="line"> SettingManager* Settings;</div><div class="line"> <span class="keywordtype">bool</span> ShouldQuit;</div><div class="line"></div><div class="line"> <span class="comment">//settings dialog</span></div><div class="line"> IGUIButton* ButtonSave;</div><div class="line"> IGUIButton* ButtonExit;</div><div class="line"> IGUIListBox* ListboxDriver;</div><div class="line"> IGUIListBox* ListboxResolution;</div><div class="line"> IGUICheckBox* CheckboxFullscreen;</div><div class="line">};</div></div><!-- fragment --><p> A typical event receiver. </p><div class="fragment"><div class="line"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> MyEventReceiver(SAppContext & a) : App(a) { }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent& event)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (event.EventType == EET_GUI_EVENT )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">switch</span> ( event.GUIEvent.EventType )</div><div class="line"> {</div><div class="line"> <span class="comment">//handle button click events</span></div><div class="line"> <span class="keywordflow">case</span> EGET_BUTTON_CLICKED:</div><div class="line"> {</div><div class="line"> <span class="comment">//Our save button was called so we obtain the settings from our dialog and save them</span></div><div class="line"> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == App.ButtonSave )</div><div class="line"> {</div><div class="line"> <span class="comment">//if there is a selection write it</span></div><div class="line"> <span class="keywordflow">if</span> ( App.ListboxDriver->getSelected() != -1)</div><div class="line"> App.Settings->setSetting(L<span class="stringliteral">"driver"</span>, App.ListboxDriver->getListItem(App.ListboxDriver->getSelected()));</div><div class="line"></div><div class="line"> <span class="comment">//if there is a selection write it</span></div><div class="line"> <span class="keywordflow">if</span> ( App.ListboxResolution->getSelected() != -1)</div><div class="line"> App.Settings->setSetting(L<span class="stringliteral">"resolution"</span>, App.ListboxResolution->getListItem(App.ListboxResolution->getSelected()));</div><div class="line"></div><div class="line"> App.Settings->setSetting(L<span class="stringliteral">"fullscreen"</span>, App.CheckboxFullscreen->isChecked());</div><div class="line"></div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (App.Settings->save())</div><div class="line"> {</div><div class="line"> App.Gui->addMessageBox(L<span class="stringliteral">"settings save"</span>,L<span class="stringliteral">"settings saved, please restart for settings to change effect"</span>,<span class="stringliteral">""</span>,<span class="keyword">true</span>);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="comment">// cancel/exit button clicked, tell the application to exit</span></div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == App.ButtonExit)</div><div class="line"> {</div><div class="line"> App.ShouldQuit = <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> SAppContext & App;</div><div class="line">};</div></div><!-- fragment --><p> Function to create a video settings dialog This dialog shows the current settings from the configuration xml and allows them to be changed </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> createSettingsDialog(SAppContext& app)</div><div class="line">{</div><div class="line"> <span class="comment">// first get rid of alpha in gui</span></div><div class="line"> <span class="keywordflow">for</span> (irr::s32 i=0; i<irr::gui::EGDC_COUNT ; ++i)</div><div class="line"> {</div><div class="line"> irr::video::SColor col = app.Gui->getSkin()->getColor((irr::gui::EGUI_DEFAULT_COLOR)i);</div><div class="line"> col.setAlpha(255);</div><div class="line"> app.Gui->getSkin()->setColor((irr::gui::EGUI_DEFAULT_COLOR)i, col);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//create video settings windows</span></div><div class="line"> gui::IGUIWindow* windowSettings = app.Gui->addWindow(rect<s32>(10,10,400,400),<span class="keyword">true</span>,L<span class="stringliteral">"Videosettings"</span>);</div><div class="line"> app.Gui->addStaticText (L<span class="stringliteral">"Select your desired video settings"</span>, rect< s32 >(10,20, 200, 40), <span class="keyword">false</span>, <span class="keyword">true</span>, windowSettings);</div><div class="line"></div><div class="line"> <span class="comment">// add listbox for driver choice</span></div><div class="line"> app.Gui->addStaticText (L<span class="stringliteral">"Driver"</span>, rect< s32 >(10,50, 200, 60), <span class="keyword">false</span>, <span class="keyword">true</span>, windowSettings);</div><div class="line"> app.ListboxDriver = app.Gui->addListBox(rect<s32>(10,60,220,120), windowSettings, 1,<span class="keyword">true</span>);</div><div class="line"></div><div class="line"> <span class="comment">//add all available options to the driver choice listbox</span></div><div class="line"> map<stringw, s32>::Iterator i = app.Settings->DriverOptions.getIterator();</div><div class="line"> <span class="keywordflow">for</span>(; !i.atEnd(); i++)</div><div class="line"> app.ListboxDriver->addItem(i->getKey().c_str());</div><div class="line"></div><div class="line"> <span class="comment">//set currently selected driver</span></div><div class="line"> app.ListboxDriver->setSelected(app.Settings->getSetting(<span class="stringliteral">"driver"</span>).c_str());</div><div class="line"></div><div class="line"> <span class="comment">// add listbox for resolution choice</span></div><div class="line"> app.Gui->addStaticText (L<span class="stringliteral">"Resolution"</span>, rect< s32 >(10,130, 200, 140), <span class="keyword">false</span>, <span class="keyword">true</span>, windowSettings);</div><div class="line"> app.ListboxResolution = app.Gui->addListBox(rect<s32>(10,140,220,200), windowSettings, 1,<span class="keyword">true</span>);</div><div class="line"></div><div class="line"> <span class="comment">//add all available options to the resolution listbox</span></div><div class="line"> map<stringw, dimension2du>::Iterator ri = app.Settings->ResolutionOptions.getIterator();</div><div class="line"> <span class="keywordflow">for</span>(; !ri.atEnd(); ri++)</div><div class="line"> app.ListboxResolution->addItem(ri->getKey().c_str());</div><div class="line"></div><div class="line"> <span class="comment">//set currently selected resolution</span></div><div class="line"> app.ListboxResolution->setSelected(app.Settings->getSetting(<span class="stringliteral">"resolution"</span>).c_str());</div><div class="line"></div><div class="line"> <span class="comment">//add checkbox to toggle fullscreen, initially set to loaded setting</span></div><div class="line"> app.CheckboxFullscreen = app.Gui->addCheckBox(</div><div class="line"> app.Settings->getSettingAsBoolean(<span class="stringliteral">"fullscreen"</span>),</div><div class="line"> rect<s32>(10,220,220,240), windowSettings, -1,</div><div class="line"> L<span class="stringliteral">"Fullscreen"</span>);</div><div class="line"></div><div class="line"> <span class="comment">//last but not least add save button</span></div><div class="line"> app.ButtonSave = app.Gui->addButton(</div><div class="line"> rect<s32>(80,250,150,270), windowSettings, 2,</div><div class="line"> L<span class="stringliteral">"Save video settings"</span>);</div><div class="line"></div><div class="line"> <span class="comment">//exit/cancel button</span></div><div class="line"> app.ButtonExit = app.Gui->addButton(</div><div class="line"> rect<s32>(160,250,240,270), windowSettings, 2,</div><div class="line"> L<span class="stringliteral">"Cancel and exit"</span>);</div><div class="line">}</div></div><!-- fragment --><p> The main function. Creates all objects and does the XML handling. </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> <span class="comment">//create new application context</span></div><div class="line"> SAppContext app;</div><div class="line"></div><div class="line"> <span class="comment">//create device creation parameters that can get overwritten by our settings file</span></div><div class="line"> SIrrlichtCreationParameters param;</div><div class="line"> param.DriverType = EDT_SOFTWARE;</div><div class="line"> param.WindowSize.set(640,480);</div><div class="line"></div><div class="line"> <span class="comment">// Try to load config.</span></div><div class="line"> <span class="comment">// I leave it as an exercise of the reader to store the configuration in the local application data folder,</span></div><div class="line"> <span class="comment">// the only logical place to store config data for games. For all other operating systems I redirect to your manuals</span></div><div class="line"> app.Settings = <span class="keyword">new</span> SettingManager(<span class="stringliteral">"../../media/settings.xml"</span>);</div><div class="line"> <span class="keywordflow">if</span> ( !app.Settings->load() )</div><div class="line"> {</div><div class="line"> <span class="comment">// ...</span></div><div class="line"> <span class="comment">// Here add your own exception handling, for now we continue because there are defaults set in SettingManager constructor</span></div><div class="line"> <span class="comment">// ...</span></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> <span class="comment">//settings xml loaded from disk,</span></div><div class="line"></div><div class="line"> <span class="comment">//map driversetting to driver type and test if the setting is valid</span></div><div class="line"> <span class="comment">//the DriverOptions map contains string representations mapped to to irrlicht E_DRIVER_TYPE enum</span></div><div class="line"> <span class="comment">//e.g "direct3d9" will become 4</span></div><div class="line"> <span class="comment">//see DriverOptions in the settingmanager class for details</span></div><div class="line"> map<stringw, s32>::Node* driver = app.Settings->DriverOptions.find( app.Settings->getSetting(<span class="stringliteral">"driver"</span>) );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (driver)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( irr::IrrlichtDevice::isDriverSupported( static_cast<E_DRIVER_TYPE>( driver->getValue() )))</div><div class="line"> {</div><div class="line"> <span class="comment">// selected driver is supported, so we use it.</span></div><div class="line"> param.DriverType = <span class="keyword">static_cast<</span>E_DRIVER_TYPE<span class="keyword">></span>( driver->getValue());</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//map resolution setting to dimension in a similar way as demonstrated above</span></div><div class="line"> map<stringw, dimension2du>::Node* res = app.Settings->ResolutionOptions.find( app.Settings->getSetting(<span class="stringliteral">"resolution"</span>) );</div><div class="line"> <span class="keywordflow">if</span> (res)</div><div class="line"> {</div><div class="line"> param.WindowSize = res->getValue();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//get fullscreen setting from config</span></div><div class="line"> param.Fullscreen = app.Settings->getSettingAsBoolean(<span class="stringliteral">"fullscreen"</span>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//create the irrlicht device using the settings</span></div><div class="line"> app.Device = createDeviceEx(param);</div><div class="line"> <span class="keywordflow">if</span> (app.Device == 0)</div><div class="line"> {</div><div class="line"> <span class="comment">// You can add your own exception handling on driver failure</span></div><div class="line"> exit(0);</div><div class="line"> }</div><div class="line"></div><div class="line"> app.Device->setWindowCaption(L<span class="stringliteral">"Xmlhandling - Irrlicht engine tutorial"</span>);</div><div class="line"> app.Driver = app.Device->getVideoDriver();</div><div class="line"> app.Gui = app.Device->getGUIEnvironment();</div><div class="line"></div><div class="line"> createSettingsDialog(app);</div><div class="line"></div><div class="line"> <span class="comment">//set event receiver so we can respond to gui events</span></div><div class="line"> MyEventReceiver receiver(app);</div><div class="line"> app.Device->setEventReceiver(&receiver);</div><div class="line"></div><div class="line"> <span class="comment">//enter main loop</span></div><div class="line"> <span class="keywordflow">while</span> (!app.ShouldQuit && app.Device->run())</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (app.Device->isWindowActive())</div><div class="line"> {</div><div class="line"> app.Driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,200,200,200));</div><div class="line"> app.Gui->drawAll();</div><div class="line"> app.Driver->endScene();</div><div class="line"> }</div><div class="line"> app.Device->sleep(10);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">//app destroys device in destructor</span></div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents --> +<!-- HTML footer for doxygen 1.8.13--> +<!-- start footer part --> +<p> </p> +</body> +</html> |
