From a22d2487d650ba5244239094a8f8a81c0c2387c9 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@993157c7-ee19-0410-b2c4-bb4e9862e678> Date: Sun, 22 Jul 2007 16:10:57 +0000 Subject: [PATCH] rough list of `todo` for openra removed (c)TOSHIBA from Openra.TechTree - beedee fails added first-pass c# support to corfu converted ijw internet's todo file into the form corfu likes palette usage analysis tool for openra, so we can find a good slot to hijack git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1319 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.Game/HardwarePalette.cs | 4 +- OpenRa.Game/Sidebar.cs | 8 +-- OpenRa.Game/Util.cs | 11 ++++ OpenRa.TechTree/Properties/AssemblyInfo.cs | 24 +------- OpenRa.sln | 12 ++++ PaletteUsage/PaletteUsage.csproj | 49 +++++++++++++++++ PaletteUsage/Program.cs | 51 +++++++++++++++++ PaletteUsage/Properties/AssemblyInfo.cs | 33 +++++++++++ todo.todo | 64 ++++++++++++++++++++++ 9 files changed, 227 insertions(+), 29 deletions(-) create mode 100644 PaletteUsage/PaletteUsage.csproj create mode 100644 PaletteUsage/Program.cs create mode 100644 PaletteUsage/Properties/AssemblyInfo.cs create mode 100644 todo.todo diff --git a/OpenRa.Game/HardwarePalette.cs b/OpenRa.Game/HardwarePalette.cs index e7a415c2fe..a249cc4bd8 100644 --- a/OpenRa.Game/HardwarePalette.cs +++ b/OpenRa.Game/HardwarePalette.cs @@ -8,6 +8,7 @@ using OpenRa.FileFormats; namespace OpenRa.Game { + // todo: synthesize selection color, and generate duplicate palette block! public class HardwarePalette { const int maxEntries = 16; // dont need anything like this many, @@ -27,8 +28,7 @@ namespace OpenRa.Game AddPalette(pal); foreach (string remap in new string[] { "blue", "red", "orange", "teal", "salmon", "green", "gray" }) - AddPalette(new Palette(pal, new PaletteRemap( - FileSystem.Open( remap + ".rem" )))); + AddPalette(new Palette(pal, new PaletteRemap(FileSystem.Open(remap + ".rem")))); } void Resolve() diff --git a/OpenRa.Game/Sidebar.cs b/OpenRa.Game/Sidebar.cs index 74fb90424f..bf6795d20c 100644 --- a/OpenRa.Game/Sidebar.cs +++ b/OpenRa.Game/Sidebar.cs @@ -15,8 +15,6 @@ namespace OpenRa.Game TechTree.TechTree techTree = new TechTree.TechTree(); SpriteRenderer spriteRenderer; - //Package package; - Sprite blank; Dictionary sprites = new Dictionary(); @@ -30,15 +28,15 @@ namespace OpenRa.Game techTree.Build("FACT", true); spriteRenderer = new SpriteRenderer(renderer, false); - LoadSprites("../../../buildings.txt"); - LoadSprites("../../../units.txt"); + LoadSprites("buildings.txt"); + LoadSprites("units.txt"); blank = SheetBuilder.Add(new Size(64, 48), 16); } void LoadSprites(string filename) { - foreach (string line in File.ReadAllLines(filename)) + foreach (string line in Util.ReadAllLines(FileSystem.Open(filename))) { string key = line.Substring(0, line.IndexOf(',')); sprites.Add(key, SpriteSheetBuilder.LoadSprite(key + "icon.shp")); diff --git a/OpenRa.Game/Util.cs b/OpenRa.Game/Util.cs index f0cae6e99e..6f1e5ff2f4 100644 --- a/OpenRa.Game/Util.cs +++ b/OpenRa.Game/Util.cs @@ -4,6 +4,7 @@ using System.Text; using OpenRa.FileFormats; using System.Drawing; using BluntDirectX.Direct3D; +using System.IO; namespace OpenRa.Game { @@ -40,6 +41,16 @@ namespace OpenRa.Game return (1 - t) * a + t * b; } + public static string[] ReadAllLines(Stream s) + { + List result = new List(); + using (StreamReader reader = new StreamReader(s)) + while (!reader.EndOfStream) + result.Add(reader.ReadLine()); + + return result.ToArray(); + } + public static T[] MakeArray(int count, Converter f) { T[] result = new T[count]; diff --git a/OpenRa.TechTree/Properties/AssemblyInfo.cs b/OpenRa.TechTree/Properties/AssemblyInfo.cs index 643e398cfb..f501b1c1a0 100644 --- a/OpenRa.TechTree/Properties/AssemblyInfo.cs +++ b/OpenRa.TechTree/Properties/AssemblyInfo.cs @@ -2,34 +2,14 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("OpenRa.TechTree")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("TOSHIBA")] +[assembly: AssemblyCompany("IJW Software")] [assembly: AssemblyProduct("OpenRa.TechTree")] -[assembly: AssemblyCopyright("Copyright © TOSHIBA 2007")] +[assembly: AssemblyCopyright("Copyright © IJW Software 2007")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("af5f7d2f-f905-4a72-9542-f86acbe508ec")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenRa.sln b/OpenRa.sln index dff2f80a26..e050956c03 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.BlockCacheVisualizer EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.DataStructures", "OpenRa.DataStructures\OpenRa.DataStructures.csproj", "{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteUsage", "PaletteUsage\PaletteUsage.csproj", "{54577061-E2D2-4336-90A2-A9A7106A30CD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -101,6 +103,16 @@ Global {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Win32.ActiveCfg = Release|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Win32.ActiveCfg = Debug|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Any CPU.Build.0 = Release|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PaletteUsage/PaletteUsage.csproj b/PaletteUsage/PaletteUsage.csproj new file mode 100644 index 0000000000..b95133a2b2 --- /dev/null +++ b/PaletteUsage/PaletteUsage.csproj @@ -0,0 +1,49 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {54577061-E2D2-4336-90A2-A9A7106A30CD} + Exe + Properties + PaletteUsage + PaletteUsage + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PaletteUsage/Program.cs b/PaletteUsage/Program.cs new file mode 100644 index 0000000000..09100e0f80 --- /dev/null +++ b/PaletteUsage/Program.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using System.Drawing; + +namespace PaletteUsage +{ + class Program + { + static void Main(string[] args) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.RestoreDirectory = true; + ofd.Filter = "PNG Image Cache (*.png)|*.png"; + + if (DialogResult.OK != ofd.ShowDialog()) + return; + + Bitmap bitmap = new Bitmap(ofd.FileName); + int[] f = new int[256]; + + foreach (byte b in ImageBytes(bitmap)) + ++f[b]; + + for (int i = 0; i < 256; i++) + { + if (i % 8 == 0) + Console.WriteLine(); + + Console.Write("{0} -> {1}", i.ToString().PadLeft(3), f[i].ToString().PadRight(8)); + } + } + + static IEnumerable ImageBytes(Bitmap bitmap) + { + int width = bitmap.Width; + int height = bitmap.Height; + + for( int i = 0; i < width; i++ ) + for (int j = 0; j < height; j++) + { + Color c = bitmap.GetPixel(i, j); + yield return (byte)c.R; + yield return (byte)c.G; + yield return (byte)c.B; + yield return (byte)c.A; + } + } + } +} diff --git a/PaletteUsage/Properties/AssemblyInfo.cs b/PaletteUsage/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5099516f48 --- /dev/null +++ b/PaletteUsage/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PaletteUsage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PaletteUsage")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("93fb03d7-e484-45a8-bfe0-c0560814553a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/todo.todo b/todo.todo new file mode 100644 index 0000000000..a33a94f62d --- /dev/null +++ b/todo.todo @@ -0,0 +1,64 @@ +OpenRA +------------------------------------------------------ + +[ ] Automagically work out unit rendering offsets based on SHP size +[ ] Ore +[ ] Better harvester logic - seek out more ore when harvesting, until full +[ ] Fix weird delegate names - Provider, Comparison, Converter, Action + should be used where appropriate. `Func` says nothing, and is damned misleading + when the delegate isnt referentially transparent... IE, not a `function`. + + Note that the lack of referential transparency for Provider cannot be helped, + it's in the nature of an object that converts () -> T. + +[ ] Palette hax for selection outlines. Basically, just hijack a palette entry that's not + getting used, and draw the selection borders into the SHP images using that color. + Then we double up the hardware palettes, and we can draw selection with no extra cost. + + (Except maybe losing any alpha=0 optimization the backend of the shader hardware does) + +[ ] Weapons +[ ] Consume more caffeine! +[ ] Multiplayer! + +[ ] Unit turn rate as specified in rules.ini +[ ] Infantry squishing logic (tracked vehicles do this) + +[ ] Time-to-build overlay on sidebar +[ ] Mod support + +[ ] Get rid of all the damned static classes! Makes it REALLY HARD to reuse code, + dependencies aren't easily visible (or even substitutable, which matters more) + +[ ] Group pathfinding logic +[ ] Special-case pathing for floating units, flying units... + Does existing pathing work for boats? float=?? speeds should tell us everything required.. + +[ ] Shroud rendering. This is going to be ugly, and it's going to hurt perf, unless we can optimize + the hell out of the other rendering based on where shroud blocks happen to be.. + +[ ] Optimize ground renderer, so we only submit visible chunks, not whole rows. + For machines with severe vertex-rate issues, use 2x2 chunks or larger for some things. + +[ ] Configuration option for choosing which tuned solution to use: + - Cope with lack of HW VP + - Cope with lack of fast texture memory (although UMA makes this almost a non-issue) + - Cope with REALLY WINFUL FAST HEAVENLY HARDWARE (The boss might want to play this :P ) + +[ ] Console +[ ] Ditch special unit classes, use templates extracted from rules.ini instead. + Push the special-case logic into code that can be named. + +[ ] Remove all remaining `../../../` bullshit from the code. We should be able to set our datapaths + externally, then `just go`. The FileSystem class is there to facilitate this. + +[ ] Read/write distinction on IFolder implementors. I think Package should be read-only, + FS folders can be mounted read-only or read-write, (or even write-only, but that's odd...) + Use FileSystem.Create() to automatically place output files on sensible mounts. + +[ ] Factor duplication out of Sheet, HardwarePalette. Both contain logic for converting bitmaps to + hardware textures on demand. +[ ] Refresh hardware image of a Sheet if its bitmap content changes. This will kill the prefetch + bugs permanently! +[ ] Solid buildings, units +