Compare commits
338 Commits
release-20
...
playtest-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6040b55d17 | ||
|
|
77fc6199fe | ||
|
|
49bf93085f | ||
|
|
aa7d688905 | ||
|
|
83929af62a | ||
|
|
6cb8ee1f9f | ||
|
|
772734d032 | ||
|
|
4576eaadd6 | ||
|
|
c20d71c9af | ||
|
|
40b89d177f | ||
|
|
314db743fc | ||
|
|
9b5c7c2379 | ||
|
|
564fdd650d | ||
|
|
bd90666c07 | ||
|
|
cd155b21c9 | ||
|
|
cbee1513f3 | ||
|
|
6932db1d05 | ||
|
|
718742be4a | ||
|
|
4ad7af8a58 | ||
|
|
57e2d4f9b1 | ||
|
|
5a029e337a | ||
|
|
bc5efa3fc5 | ||
|
|
192cbaf744 | ||
|
|
053d661ed7 | ||
|
|
9ac912fa0e | ||
|
|
b6c2b928cb | ||
|
|
58b437b7ea | ||
|
|
7498af6b66 | ||
|
|
b88a32759c | ||
|
|
c9fd874b07 | ||
|
|
a060d99780 | ||
|
|
7bc7fbc006 | ||
|
|
ce8bcd1576 | ||
|
|
465f917836 | ||
|
|
de7fbfc927 | ||
|
|
2eac701aab | ||
|
|
0edda0fb31 | ||
|
|
72c6a428c9 | ||
|
|
986bf039fa | ||
|
|
4dc3013cd0 | ||
|
|
58cae272c6 | ||
|
|
1df9003fec | ||
|
|
f83c9fd4d7 | ||
|
|
8111ccbea6 | ||
|
|
c50aae25d3 | ||
|
|
7a6f4d3b04 | ||
|
|
eaa4d06052 | ||
|
|
53599f062c | ||
|
|
2a64df997a | ||
|
|
5bb535b50c | ||
|
|
77ebd5d6de | ||
|
|
9279161de6 | ||
|
|
268f06caf0 | ||
|
|
3a5cce1f1f | ||
|
|
bfddbeeb02 | ||
|
|
92f5d67ef1 | ||
|
|
e602e086f3 | ||
|
|
35b0231746 | ||
|
|
f5807f5f3b | ||
|
|
d9fbee6e01 | ||
|
|
a04ab94717 | ||
|
|
4f505eb6a1 | ||
|
|
6174ccc882 | ||
|
|
7cc0a45727 | ||
|
|
deeef336a1 | ||
|
|
ce8267992a | ||
|
|
b9ac25e044 | ||
|
|
4168e54715 | ||
|
|
aef3ff6e65 | ||
|
|
eebfb34ea2 | ||
|
|
b1b9d1fca2 | ||
|
|
7d9641e195 | ||
|
|
9e21282341 | ||
|
|
935c2eff31 | ||
|
|
ff86c4d7fa | ||
|
|
143f9e0e84 | ||
|
|
dec8c8ba4b | ||
|
|
c0b5455016 | ||
|
|
e7ed9a1ff7 | ||
|
|
eec751f76a | ||
|
|
52cec1e170 | ||
|
|
a290af6fb5 | ||
|
|
c8122a13ff | ||
|
|
00372f4748 | ||
|
|
4c26710ccb | ||
|
|
4a30019536 | ||
|
|
0c2e1f81da | ||
|
|
7106f1fe74 | ||
|
|
0a977b2940 | ||
|
|
6010034b4a | ||
|
|
4c8e048c2c | ||
|
|
88bfee872f | ||
|
|
3548dacad3 | ||
|
|
b7b2db9ace | ||
|
|
b119c14599 | ||
|
|
d47c4f7ca2 | ||
|
|
808464f4d5 | ||
|
|
f5c4a94f93 | ||
|
|
a7c276849d | ||
|
|
10733c3a31 | ||
|
|
03ddbac83b | ||
|
|
a3897dc7a8 | ||
|
|
2d4b00ec2a | ||
|
|
42aa8a57c5 | ||
|
|
1c69f5bef9 | ||
|
|
511c956117 | ||
|
|
a5547eac97 | ||
|
|
325ec41182 | ||
|
|
a1dd5cedd4 | ||
|
|
c790c41465 | ||
|
|
7161b8062e | ||
|
|
eddc4cc4b1 | ||
|
|
12968ff9b9 | ||
|
|
7ef93f2cf5 | ||
|
|
59fdceb4fd | ||
|
|
0f7a744ef7 | ||
|
|
50010faf58 | ||
|
|
89ea4d1e0a | ||
|
|
bc6af1841b | ||
|
|
227bbc109e | ||
|
|
737756be51 | ||
|
|
1d5201d797 | ||
|
|
e29f838425 | ||
|
|
3432ce256a | ||
|
|
cd8f8dbc0f | ||
|
|
b912f69212 | ||
|
|
4812eb95b6 | ||
|
|
ea0348977e | ||
|
|
2566b44627 | ||
|
|
3716f0561c | ||
|
|
1e32014190 | ||
|
|
d9d0e74d74 | ||
|
|
3991026cf3 | ||
|
|
d202f9627f | ||
|
|
770cdf38b6 | ||
|
|
1e67984806 | ||
|
|
5b23fd4873 | ||
|
|
35d167a4fd | ||
|
|
32d466ba10 | ||
|
|
6ef8dbf282 | ||
|
|
8de52cf7bc | ||
|
|
261c4c5b62 | ||
|
|
603a29b70d | ||
|
|
0d0d91113c | ||
|
|
536388ab5c | ||
|
|
03b3649e54 | ||
|
|
16aec6ba90 | ||
|
|
47757161d6 | ||
|
|
26b9feaf4b | ||
|
|
c4256faf18 | ||
|
|
c39050fdda | ||
|
|
f085b79491 | ||
|
|
206cb88146 | ||
|
|
eda7f17ad8 | ||
|
|
7f1918d07b | ||
|
|
59e4dd666a | ||
|
|
1a15398605 | ||
|
|
75e65bf4c5 | ||
|
|
81316a240b | ||
|
|
ac263697da | ||
|
|
20c4db914c | ||
|
|
ea3ad0e378 | ||
|
|
2c415a8fd6 | ||
|
|
a34b2d8c53 | ||
|
|
e2cbfb920b | ||
|
|
1f1c2b25b0 | ||
|
|
eaf15fa6b5 | ||
|
|
d2740847cf | ||
|
|
62e9f5c3f7 | ||
|
|
9d8ff12d23 | ||
|
|
7864aeed37 | ||
|
|
dc8726a6a0 | ||
|
|
3027c9d6f2 | ||
|
|
bdf9447798 | ||
|
|
756a3e551d | ||
|
|
2da46a418f | ||
|
|
88554a5039 | ||
|
|
9f86ef526f | ||
|
|
57308773a2 | ||
|
|
d6f4b61b1c | ||
|
|
6922ff3bf9 | ||
|
|
1702a9e9f5 | ||
|
|
38b6d3527b | ||
|
|
9719e10edd | ||
|
|
c7f780eb1d | ||
|
|
a193eeb202 | ||
|
|
957c1cc74c | ||
|
|
92bdec7f1d | ||
|
|
cf46a7ed5f | ||
|
|
f966c08fed | ||
|
|
be8682fc19 | ||
|
|
12b8774e6d | ||
|
|
6c78bb481d | ||
|
|
f79dfd51a2 | ||
|
|
8e3bcb892f | ||
|
|
9b826d91a4 | ||
|
|
d802cbfd9d | ||
|
|
22288d10e2 | ||
|
|
ce336b46fd | ||
|
|
9fdfca6ee5 | ||
|
|
5ced7e270c | ||
|
|
87223f5b64 | ||
|
|
52daca603b | ||
|
|
0fbc6c0a54 | ||
|
|
e9a4ec5403 | ||
|
|
281f706b02 | ||
|
|
8ab40bc5e8 | ||
|
|
928cfb1f31 | ||
|
|
dea66818cd | ||
|
|
c18dcca1bc | ||
|
|
1cf12df1c4 | ||
|
|
b9e22f50ed | ||
|
|
2bc260c833 | ||
|
|
3cf15b870a | ||
|
|
ec8c5849eb | ||
|
|
c76ebe51a5 | ||
|
|
8f560d79fd | ||
|
|
6d469a1414 | ||
|
|
57ac95123e | ||
|
|
c260635228 | ||
|
|
2a48e01d91 | ||
|
|
d3b5939613 | ||
|
|
bdcd8097e5 | ||
|
|
dfa456a537 | ||
|
|
f936bbeaf7 | ||
|
|
e02a6e7ec4 | ||
|
|
baa79c2dbc | ||
|
|
23e101deb0 | ||
|
|
0a88a6da8e | ||
|
|
84234e8794 | ||
|
|
9eecd7ba6b | ||
|
|
9c35debd46 | ||
|
|
dc850d3f73 | ||
|
|
05ce48b732 | ||
|
|
554032ad5f | ||
|
|
e5a1658d87 | ||
|
|
2df7a657d3 | ||
|
|
8174e7fffb | ||
|
|
49a758f031 | ||
|
|
fb8fdb5899 | ||
|
|
6de9c0b432 | ||
|
|
c42a39e064 | ||
|
|
4fd3e6a390 | ||
|
|
1dc0fbb625 | ||
|
|
b0747cafa8 | ||
|
|
04a8801f08 | ||
|
|
06043512db | ||
|
|
0d4f48822a | ||
|
|
06e1a6a38d | ||
|
|
1776b17205 | ||
|
|
c27af37541 | ||
|
|
174ec12ff0 | ||
|
|
4f5bfceb3f | ||
|
|
edecd166a2 | ||
|
|
632ae08b87 | ||
|
|
e4afaf4344 | ||
|
|
9663316c6c | ||
|
|
ed1b8080df | ||
|
|
567a82fd5d | ||
|
|
f9eb62beee | ||
|
|
6b602d5262 | ||
|
|
7cbd2cb9b6 | ||
|
|
54922a74b1 | ||
|
|
07175277f1 | ||
|
|
c4d10f5637 | ||
|
|
fdd0897927 | ||
|
|
623fde709f | ||
|
|
d3cdb82479 | ||
|
|
55036cd58c | ||
|
|
0eb98ef3b5 | ||
|
|
f3ee2d589b | ||
|
|
cef45a890a | ||
|
|
67933fe253 | ||
|
|
7b3de29f05 | ||
|
|
1216cef981 | ||
|
|
d3bfcfea5c | ||
|
|
1c2f857222 | ||
|
|
9fcddc0df2 | ||
|
|
23202eff0c | ||
|
|
73f4997f6d | ||
|
|
ef71020835 | ||
|
|
420052b12c | ||
|
|
e7900d069d | ||
|
|
15d846bfb0 | ||
|
|
635315b0af | ||
|
|
4bc963d621 | ||
|
|
b83fa764d4 | ||
|
|
589d201a16 | ||
|
|
6a78eec512 | ||
|
|
c608b45ef0 | ||
|
|
68801ba7b5 | ||
|
|
657e8ad250 | ||
|
|
a1fc76acc3 | ||
|
|
73676c8f0c | ||
|
|
1eec17d430 | ||
|
|
b76ec11304 | ||
|
|
6c39f19a73 | ||
|
|
3b2efc7b0b | ||
|
|
e829e4b5aa | ||
|
|
f6661d5e47 | ||
|
|
2063277654 | ||
|
|
c1ec8fdd5c | ||
|
|
589f590fdc | ||
|
|
538779e249 | ||
|
|
025dccaa3f | ||
|
|
776a1aa817 | ||
|
|
9480846250 | ||
|
|
24c74dcdd9 | ||
|
|
bc8f02375f | ||
|
|
c1f522db63 | ||
|
|
16fa2f2c1e | ||
|
|
7458deab81 | ||
|
|
4e52dca3b6 | ||
|
|
575641155c | ||
|
|
561bec9ada | ||
|
|
be1a041a8c | ||
|
|
44f65f15ea | ||
|
|
25e257f2fa | ||
|
|
446193ecc7 | ||
|
|
9942c4cbf8 | ||
|
|
a8097b1872 | ||
|
|
2b9d21feb7 | ||
|
|
9de1ed9761 | ||
|
|
ea190fcf86 | ||
|
|
21ae6ee983 | ||
|
|
03adb7f2c3 | ||
|
|
c9c716aae4 | ||
|
|
9ee794ee1f | ||
|
|
b2cf3d9513 | ||
|
|
7306f92d22 | ||
|
|
2cc6a67a95 | ||
|
|
460696192b | ||
|
|
be9948426c | ||
|
|
1d052bbfa2 | ||
|
|
00c6c5c88d | ||
|
|
a3818a6aa2 | ||
|
|
cc18a6a515 | ||
|
|
aec4e6b5e8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,6 +7,7 @@ obj
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.cache
|
||||
*.manifest
|
||||
mods/*/*.dll
|
||||
|
||||
# Red Alert binary files
|
||||
@@ -55,3 +56,5 @@ OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3
|
||||
Logs/
|
||||
Replays/
|
||||
settings.yaml
|
||||
\#*
|
||||
.*.sw?
|
||||
|
||||
48
AUTHORS
48
AUTHORS
@@ -1,14 +1,34 @@
|
||||
AUTHORS
|
||||
|
||||
The OpenRA developers are:
|
||||
* Chris Forbes
|
||||
* Robert Pepperell
|
||||
* Matthew Bowra-Dean
|
||||
* Paul Chote
|
||||
* Alli Witheford
|
||||
* Joakim Lindberg
|
||||
* Andrew Riedi
|
||||
* Tim Mylemans
|
||||
* Curtis Shmyr
|
||||
* Caleb Anderson
|
||||
* Daniel Hernandez
|
||||
AUTHORS
|
||||
|
||||
The OpenRA developers are:
|
||||
* Alli Witheford (alzeih)
|
||||
* Caleb Anderson (RobotCaleb)
|
||||
* Chris Forbes (chrisf)
|
||||
* Curtis Shmyr (hamb)
|
||||
* Daniel Hernandez (Mancano)
|
||||
* Matthew Bowra-Dean (beedee)
|
||||
* Mike Bundy (kehaar)
|
||||
|
||||
Also thanks to:
|
||||
* Andrew Riedi
|
||||
* Bellator
|
||||
* Christer Ulfsparre (Holloweye)
|
||||
* Erasmus Schroder (rasco)
|
||||
* Igor Popov (ihptru)
|
||||
* Jeff Harris (jeff_1amstudios)
|
||||
* Joakim Lindberg (booom3)
|
||||
* Max Ugrumov (katzsmile)
|
||||
* Lawrence Wang
|
||||
* Matthew Gatland (mgatland)
|
||||
* Max621
|
||||
* Nukem
|
||||
* Paolo Chiodi (paolochiodi)
|
||||
* Paul Dovydaitis (pdovy)
|
||||
* Ragequit
|
||||
* Tim Mylemans (gecko)
|
||||
* Riderr3
|
||||
* Raymond Martineau
|
||||
|
||||
Past developers included:
|
||||
* Paul Chote (pchote)
|
||||
* Robert Pepperell (ytinasni)
|
||||
|
||||
105
CHANGELOG
105
CHANGELOG
@@ -1,3 +1,108 @@
|
||||
NEW:
|
||||
Engine:
|
||||
General performance improvements
|
||||
Fixed minimap export breaking subsequent actions in the editor
|
||||
Added owner chooser for new actors in the editor
|
||||
Added actor info panel in the editor (doubleclick)
|
||||
Added a Setup Default Players menu item to map editor
|
||||
Both Mods:
|
||||
Server lobbies upon creation use the previously played map
|
||||
Added support for a Game.ConnectTo argument which allows clients to direct connect to a server when game is launched
|
||||
Helicopters now bob slightly in flight
|
||||
Bots now repair their own buildings
|
||||
Fixed a bug where bots would be unable to set rallypoints for production buildings
|
||||
Bots now maintain a level of aggro on enemy units
|
||||
Made SpawnMPUnits' initial unit configurable
|
||||
Added a dropdown list in the map editor for setting an actor's owner upon placement
|
||||
Replaced the server browser with a new and awesome one
|
||||
Fixed a bug where infantry squish sounds weren't positioned
|
||||
Fixed a bug where actor priority wasn't correct for doubleclick
|
||||
|
||||
Red Alert:
|
||||
Fixed a crash which occurred when playing an online game with Hard AI
|
||||
Fixed a bug where planes could stack more than 1-per-airfield
|
||||
Fixed a bug where planes would not rearm at airfields
|
||||
Improved logic for sending planes and helicopters back to base
|
||||
Changed MIG to fire 2 missiles per burst instead of 4
|
||||
Changed HELI (longbow) to fire missiles in bursts of 2
|
||||
Added a Show Shellmap setting
|
||||
Changed team color picker to match C&C's
|
||||
Fixed a bug where infantry could not pass over anti-tank mines, and vice versa
|
||||
Fixed a bug where the shellmap would reload unnecessarily when disconnecting from a lobby that hasn't started
|
||||
Added AutoTarget capability to submarines, but they are set to HoldFire stance by default
|
||||
New Map: Bombardment Islands (Sprog)
|
||||
New Map: Engagement (Nukem)
|
||||
New Map: Man to Man (Nukem)
|
||||
New Map: Asymetric Battle (Seru)
|
||||
C&C:
|
||||
Changed the bot spawn picker to match RA's
|
||||
Reduced delay of tooltips
|
||||
|
||||
20111013:
|
||||
Engine:
|
||||
Fixed broken client IDs if players drop before the game starts
|
||||
Converted FileExtractor into --extract cmdlet for Utility.
|
||||
Added --transparent option to --png cmdlet in Utility.
|
||||
Fixed shortcut description on Linux
|
||||
Fixed launcher crashes on Mac
|
||||
Removed obsolete SequenceEditor tool
|
||||
Added --tmp-png cmdlet in Utility, to convert terrain to PNG.
|
||||
Both Mods:
|
||||
Allow building repair by allies
|
||||
Use player color to show who is repairing a building
|
||||
Only units/structures being built or queued are shaded in the production palette
|
||||
Aircraft smoke is no longer visible under fog
|
||||
Added a Show Grid option to the Map Editor
|
||||
Added multitap support - double clicking a unit selects all units of the same type on screen
|
||||
Changed map choosers to be a filterable grid of maps
|
||||
Added internal machinery for IFV-style units
|
||||
Red Alert:
|
||||
Added naval transport
|
||||
Added an indicator over powered down buildings
|
||||
Aircraft crashing into water now use large_splash
|
||||
Destroyer now requires Radar Dome
|
||||
Increased cost of Shipyard and Sub Pen
|
||||
Fixed a crash when sending aircraft back to base
|
||||
Husks no longer interfere with selection
|
||||
Added more options for bots in game lobby
|
||||
Changed AI behavior -- now has Easy/Normal/Hard difficulty
|
||||
Increased range of FTUR by 1
|
||||
Reduced cost of MEDI from 500 to 300
|
||||
Reduced cost of SHOK from 800 to 500
|
||||
Heavy vehicles (Tanks, Harvesters, MCV) now crush infantry
|
||||
New map: Classic DropZone (Holloweye)
|
||||
New map: DropZone Battle of Tikiaki (Knivesron)
|
||||
New map: DropZone W (Riderr3)
|
||||
New map: Seven Stairs (Tirili)
|
||||
New map: Contact (Nukem)
|
||||
New map: Encounter (Nukem)
|
||||
New map: Mass Confliction (Nukem)
|
||||
New map: Calm before the Storm (Nukem)
|
||||
New map: Baywatch (Nukem)
|
||||
New map: Winter Warzone (Nukem)
|
||||
New map: Paramount (Nukem)
|
||||
New map: Doubles (Nukem)
|
||||
New map: Hectic (Nukem)
|
||||
New map: Pandemonium (Nukem)
|
||||
New map: Chokepoint (Nukem)
|
||||
New map: HotZone (Nukem)
|
||||
New map: No Fly Zone (RAGEQUIT)
|
||||
New map: Strip Mine (RAGEQUIT)
|
||||
New map: Doughnut Hole (RAGEQUIT)
|
||||
New map: Vegetation (hamb/Chris Forbes)
|
||||
New map: Arctic Triangle Affair (Bellator)
|
||||
New map: Mad Scramble (Bellator)
|
||||
New map: Free Coasts (Ihptru)
|
||||
New map: Battle Lake (Bellator)
|
||||
C&C:
|
||||
Slightly increased Tiberium growth rate
|
||||
Increased harvester unload time
|
||||
Reduced Tiberium value by 20%
|
||||
Changed FTNK armor type to Light
|
||||
Fixed tank squish animations to show properly
|
||||
New map: Tiberium Oasis (Bellator)
|
||||
|
||||
|
||||
20110906:
|
||||
Engine:
|
||||
Fixed compile failures under Windows
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace FileExtractor
|
||||
{
|
||||
public class FileExtractor
|
||||
{
|
||||
int Length = 256;
|
||||
|
||||
public FileExtractor (string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.WriteLine("usage: FileExtractor mod[,mod]* filename");
|
||||
return;
|
||||
}
|
||||
|
||||
var mods = args[0].Split(',');
|
||||
var manifest = new Manifest(mods);
|
||||
FileSystem.LoadFromManifest( manifest );
|
||||
|
||||
try
|
||||
{
|
||||
var readStream = FileSystem.Open(args[1]);
|
||||
var writeStream = new FileStream(args[1], FileMode.OpenOrCreate, FileAccess.Write);
|
||||
|
||||
WriteOutFile(readStream, writeStream);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine(String.Format("No Such File {0}", args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
void WriteOutFile (Stream readStream, Stream writeStream)
|
||||
{
|
||||
Byte[] buffer = new Byte[Length];
|
||||
int bytesRead = readStream.Read(buffer,0,Length);
|
||||
|
||||
while( bytesRead > 0 )
|
||||
{
|
||||
writeStream.Write(buffer,0,bytesRead);
|
||||
bytesRead = readStream.Read(buffer,0,Length);
|
||||
}
|
||||
readStream.Close();
|
||||
writeStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{210645C7-E99E-46B6-863E-E211AE6C7D70}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>FileExtractor</RootNamespace>
|
||||
<AssemblyName>FileExtractor</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="FileExtractor.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,23 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace FileExtractor
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
new FileExtractor(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
INSTALL
16
INSTALL
@@ -22,7 +22,7 @@ WINDOWS:
|
||||
* Cg Toolkit >= 2.2
|
||||
(http://developer.download.nvidia.com/cg/Cg_2.2/Cg-2.2_October2009_Setup.exe)
|
||||
|
||||
To compile OpenRA, open the OpenRA.sln solution in the main folder,
|
||||
To compile OpenRA, open the OpenRA.sln solution in the main folder,
|
||||
or build it from the command-line with MSBuild.
|
||||
|
||||
Run the game with `OpenRA.Game.exe Game.Mods=ra` for Red Alert
|
||||
@@ -37,11 +37,9 @@ UBUNTU (substitute comparable packages for other linux distros):
|
||||
* libmono-winforms2.0-cil
|
||||
* libopenal1
|
||||
* libsdl1.2-dev
|
||||
* nvidia-cg-toolkit (download the latest version from
|
||||
http://developer.nvidia.com/object/cg_download.html)
|
||||
* nvidia-cg-toolkit (for Cg renderer)
|
||||
|
||||
OpenRA is incompatible with Compiz, please disable desktop effects when trying
|
||||
to run OpenRA or the game will crash.
|
||||
OpenRA does not work with some older versions of Compiz. On affected systems, disable desktop effects before playing. This is fixed in Ubuntu Natty and later.
|
||||
|
||||
You will additionally need to copy the third party dependencies (.dll and .config) from the
|
||||
thirdparty and thirdparty/Tao directories into the game root:
|
||||
@@ -62,3 +60,11 @@ other applications that use Tao:
|
||||
To compile OpenRA, run `make' from the command line.
|
||||
Run the game with `mono OpenRA.Game.exe Game.Mods=ra` for Red Alert
|
||||
or `mono OpenRA.Game.exe Game.Mods=cnc` for Command & Conquer
|
||||
|
||||
SLACKWARE:
|
||||
|
||||
The following packages from slackbuilds.org are required, on 13.37 32bit:
|
||||
* libgdiplus
|
||||
* mono
|
||||
* openAL
|
||||
* nvidia-cg-toolkit (for Cg renderer)
|
||||
|
||||
23
Makefile
23
Makefile
@@ -6,7 +6,7 @@ PHONY = core tools package all mods clean distclean
|
||||
|
||||
.SUFFIXES:
|
||||
core: game renderers mod_ra mod_cnc utility
|
||||
tools: editor ralint seqed filex tsbuild
|
||||
tools: editor ralint tsbuild
|
||||
package: core editor
|
||||
mods: mod_ra mod_cnc
|
||||
all: core tools
|
||||
@@ -100,18 +100,6 @@ mod_cnc: $(mod_cnc_TARGET)
|
||||
#
|
||||
# Tools
|
||||
#
|
||||
# Sequence editor (defunct)
|
||||
seqed_SRCS := $(shell find SequenceEditor/ -iname '*.cs')
|
||||
seqed_TARGET = SequenceEditor.exe
|
||||
seqed_KIND = winexe
|
||||
seqed_DEPS = $(fileformats_TARGET)
|
||||
seqed_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(seqed_DEPS)
|
||||
seqed_EXTRA = -resource:SequenceEditor.Form1.resources
|
||||
PROGRAMS += seqed
|
||||
SequenceEditor.Form1.resources:
|
||||
resgen2 SequenceEditor/Form1.resx SequenceEditor.Form1.resources 1> /dev/null
|
||||
seqed: SequenceEditor.Form1.resources $(seqed_TARGET)
|
||||
|
||||
# Map Editor
|
||||
editor_SRCS := $(shell find OpenRA.Editor/ -iname '*.cs')
|
||||
editor_TARGET = OpenRA.Editor.exe
|
||||
@@ -137,15 +125,6 @@ ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS)
|
||||
PROGRAMS += ralint
|
||||
ralint: $(ralint_TARGET)
|
||||
|
||||
# Extracts files from packages (mixfiles, zips, etc)
|
||||
filex_SRCS := $(shell find FileExtractor/ -iname '*.cs')
|
||||
filex_TARGET = FileExtractor.exe
|
||||
filex_KIND = exe
|
||||
filex_DEPS = $(fileformats_TARGET)
|
||||
filex_LIBS = $(COMMON_LIBS) $(filex_DEPS)
|
||||
PROGRAMS += filex
|
||||
filex: $(filex_TARGET)
|
||||
|
||||
# Builds and exports tilesets from a bitmap
|
||||
tsbuild_SRCS := $(shell find OpenRA.TilesetBuilder/ -iname '*.cs')
|
||||
tsbuild_TARGET = TilesetBuilder.exe
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace SequenceEditor
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
partial class GetTextForm
|
||||
partial class ActorPropertiesDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -38,67 +28,65 @@ namespace SequenceEditor
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBox1.Location = new System.Drawing.Point(13, 13);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(337, 20);
|
||||
this.textBox1.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button1.Location = new System.Drawing.Point(194, 50);
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(226, 333);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
this.button1.Text = "OK";
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button2.Location = new System.Drawing.Point(275, 50);
|
||||
this.button2.Enabled = false;
|
||||
this.button2.Location = new System.Drawing.Point(145, 333);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 2;
|
||||
this.button2.Text = "Cancel";
|
||||
this.button2.TabIndex = 0;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GetTextForm
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.AcceptButton = this.button1;
|
||||
this.flowLayoutPanel1.AutoScroll = true;
|
||||
this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(13, 13);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(288, 314);
|
||||
this.flowLayoutPanel1.TabIndex = 1;
|
||||
//
|
||||
// ActorPropertiesDialog
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.button2;
|
||||
this.ClientSize = new System.Drawing.Size(362, 85);
|
||||
this.CancelButton = this.button1;
|
||||
this.ClientSize = new System.Drawing.Size(313, 368);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "GetTextForm";
|
||||
this.Name = "ActorPropertiesDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Placeholder";
|
||||
this.Text = "Actor Properties";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
}
|
||||
}
|
||||
49
OpenRA.Editor/ActorPropertiesDialog.cs
Normal file
49
OpenRA.Editor/ActorPropertiesDialog.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
public partial class ActorPropertiesDialog : Form
|
||||
{
|
||||
public ActorPropertiesDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void AddRow(string name, Control c)
|
||||
{
|
||||
flowLayoutPanel1.Controls.Add(new Label
|
||||
{
|
||||
Text = name,
|
||||
Width = flowLayoutPanel1.Width * 3 / 10,
|
||||
Height = 25,
|
||||
TextAlign = ContentAlignment.MiddleLeft,
|
||||
});
|
||||
|
||||
c.Width = flowLayoutPanel1.Width * 6 / 10 - 25;
|
||||
c.Height = 25;
|
||||
flowLayoutPanel1.Controls.Add(c);
|
||||
}
|
||||
|
||||
public Control MakeEditorControl(Type t, Func<object> getter, Action<object> setter)
|
||||
{
|
||||
var r = new TextBox();
|
||||
r.Text = FieldSaver.FormatValue(getter(), t);
|
||||
r.LostFocus += (e,_) => setter(FieldLoader.GetValue("<editor internals>", t, r.Text));
|
||||
r.Enabled = false;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -22,10 +22,8 @@ namespace OpenRA.Editor
|
||||
|
||||
public void Preview(Surface surface, SGraphics g)
|
||||
{
|
||||
/* todo: include the player
|
||||
* in the brush so we can color new buildings too */
|
||||
|
||||
surface.DrawActor(g, surface.GetBrushLocation(), Actor, null);
|
||||
surface.DrawActor(g, surface.GetBrushLocation(), Actor,
|
||||
surface.GetPaletteForPlayer(surface.NewActorOwner));
|
||||
}
|
||||
|
||||
public void Apply(Surface surface)
|
||||
@@ -33,7 +31,7 @@ namespace OpenRA.Editor
|
||||
if (surface.Map.Actors.Value.Any(a => a.Value.Location() == surface.GetBrushLocation()))
|
||||
return;
|
||||
|
||||
var owner = "Neutral";
|
||||
var owner = surface.NewActorOwner;
|
||||
var id = NextActorName(surface);
|
||||
surface.Map.Actors.Value[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -26,8 +26,8 @@ namespace OpenRA.Editor
|
||||
public void Apply(Surface surface)
|
||||
{
|
||||
// change the bits in the map
|
||||
var tile = surface.TileSet.Tiles[Brush.N];
|
||||
var template = surface.TileSet.Templates[Brush.N];
|
||||
var tile = template.Data;
|
||||
var pos = surface.GetBrushLocation();
|
||||
|
||||
if (surface.GetModifiers() == Keys.Shift)
|
||||
|
||||
18
OpenRA.Editor/ErrorListDialog.Designer.cs
generated
18
OpenRA.Editor/ErrorListDialog.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -42,9 +42,9 @@ namespace OpenRA.Editor
|
||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
//
|
||||
// label1
|
||||
//
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.Location = new System.Drawing.Point(10, 9);
|
||||
@@ -52,9 +52,9 @@ namespace OpenRA.Editor
|
||||
this.label1.Size = new System.Drawing.Size(610, 23);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Your map import completed, but with errors:";
|
||||
//
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
//
|
||||
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -63,9 +63,9 @@ namespace OpenRA.Editor
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.Size = new System.Drawing.Size(607, 316);
|
||||
this.listBox1.TabIndex = 1;
|
||||
//
|
||||
//
|
||||
// button1
|
||||
//
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(545, 359);
|
||||
@@ -74,9 +74,9 @@ namespace OpenRA.Editor
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Close";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// ErrorListDialog
|
||||
//
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(632, 394);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
97
OpenRA.Editor/Form1.Designer.cs
generated
97
OpenRA.Editor/Form1.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -47,12 +47,13 @@ namespace OpenRA.Editor
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.tilePalette = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.actorPalette = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.actorOwnerChooser = new System.Windows.Forms.ComboBox();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.resourcePalette = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.surface1 = new OpenRA.Editor.Surface();
|
||||
this.tt = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -73,12 +74,14 @@ namespace OpenRA.Editor
|
||||
this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showActorNamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showGridToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fixOpenAreasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.setupDefaultPlayersMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelFiller = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelMousePosition = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.fixOpenAreasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
@@ -89,6 +92,7 @@ namespace OpenRA.Editor
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.tabPage3.SuspendLayout();
|
||||
this.splitContainer3.Panel1.SuspendLayout();
|
||||
this.splitContainer3.Panel2.SuspendLayout();
|
||||
@@ -182,7 +186,8 @@ namespace OpenRA.Editor
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.actorPalette);
|
||||
this.tabPage2.Controls.Add(this.panel1);
|
||||
this.tabPage2.Controls.Add(this.actorOwnerChooser);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 20);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
@@ -191,15 +196,37 @@ namespace OpenRA.Editor
|
||||
this.tabPage2.Text = "Actors";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.actorPalette);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(3, 24);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(184, 525);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// actorPalette
|
||||
//
|
||||
this.actorPalette.AutoScroll = true;
|
||||
this.actorPalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.actorPalette.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.actorPalette.Location = new System.Drawing.Point(3, 3);
|
||||
this.actorPalette.Location = new System.Drawing.Point(0, 0);
|
||||
this.actorPalette.Name = "actorPalette";
|
||||
this.actorPalette.Size = new System.Drawing.Size(184, 546);
|
||||
this.actorPalette.TabIndex = 2;
|
||||
this.actorPalette.Size = new System.Drawing.Size(184, 525);
|
||||
this.actorPalette.TabIndex = 3;
|
||||
//
|
||||
// actorOwnerChooser
|
||||
//
|
||||
this.actorOwnerChooser.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.actorOwnerChooser.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.actorOwnerChooser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.actorOwnerChooser.FormattingEnabled = true;
|
||||
this.actorOwnerChooser.Location = new System.Drawing.Point(3, 3);
|
||||
this.actorOwnerChooser.Name = "actorOwnerChooser";
|
||||
this.actorOwnerChooser.Size = new System.Drawing.Size(184, 21);
|
||||
this.actorOwnerChooser.TabIndex = 3;
|
||||
this.actorOwnerChooser.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.onDrawPlayerItem);
|
||||
this.actorOwnerChooser.SelectionChangeCommitted += new System.EventHandler(this.onSelectOwner);
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
@@ -235,12 +262,6 @@ namespace OpenRA.Editor
|
||||
//
|
||||
this.tt.ShowAlways = true;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.DefaultExt = "*.png";
|
||||
this.saveFileDialog.Filter = "PNG Image (*.png)|";
|
||||
this.saveFileDialog.Title = "Export minimap to PNG";
|
||||
//
|
||||
// splitContainer3
|
||||
//
|
||||
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
@@ -395,7 +416,9 @@ namespace OpenRA.Editor
|
||||
this.propertiesToolStripMenuItem,
|
||||
this.resizeToolStripMenuItem,
|
||||
this.showActorNamesToolStripMenuItem,
|
||||
this.fixOpenAreasToolStripMenuItem});
|
||||
this.showGridToolStripMenuItem,
|
||||
this.fixOpenAreasToolStripMenuItem,
|
||||
this.setupDefaultPlayersMenuItem});
|
||||
this.mapToolStripMenuItem.Name = "mapToolStripMenuItem";
|
||||
this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23);
|
||||
this.mapToolStripMenuItem.Text = "&Map";
|
||||
@@ -405,7 +428,7 @@ namespace OpenRA.Editor
|
||||
this.propertiesToolStripMenuItem.Enabled = false;
|
||||
this.propertiesToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("propertiesToolStripMenuItem.Image")));
|
||||
this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem";
|
||||
this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.propertiesToolStripMenuItem.Text = "&Properties...";
|
||||
this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.PropertiesClicked);
|
||||
//
|
||||
@@ -414,17 +437,38 @@ namespace OpenRA.Editor
|
||||
this.resizeToolStripMenuItem.Enabled = false;
|
||||
this.resizeToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("resizeToolStripMenuItem.Image")));
|
||||
this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem";
|
||||
this.resizeToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.resizeToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.resizeToolStripMenuItem.Text = "&Resize...";
|
||||
this.resizeToolStripMenuItem.Click += new System.EventHandler(this.ResizeClicked);
|
||||
//
|
||||
// showActorNamesToolStripMenuItem
|
||||
//
|
||||
this.showActorNamesToolStripMenuItem.Name = "showActorNamesToolStripMenuItem";
|
||||
this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names";
|
||||
this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked);
|
||||
//
|
||||
// showGridToolStripMenuItem
|
||||
//
|
||||
this.showGridToolStripMenuItem.Name = "showGridToolStripMenuItem";
|
||||
this.showGridToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.showGridToolStripMenuItem.Text = "Show &Grid";
|
||||
this.showGridToolStripMenuItem.Click += new System.EventHandler(this.ShowGridClicked);
|
||||
//
|
||||
// fixOpenAreasToolStripMenuItem
|
||||
//
|
||||
this.fixOpenAreasToolStripMenuItem.Name = "fixOpenAreasToolStripMenuItem";
|
||||
this.fixOpenAreasToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.fixOpenAreasToolStripMenuItem.Text = "&Fix Open Areas";
|
||||
this.fixOpenAreasToolStripMenuItem.Click += new System.EventHandler(this.FixOpenAreas);
|
||||
//
|
||||
// setupDefaultPlayersMenuItem
|
||||
//
|
||||
this.setupDefaultPlayersMenuItem.Name = "setupDefaultPlayersMenuItem";
|
||||
this.setupDefaultPlayersMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.setupDefaultPlayersMenuItem.Text = "&Setup Default Players";
|
||||
this.setupDefaultPlayersMenuItem.Click += new System.EventHandler(this.SetupDefaultPlayers);
|
||||
//
|
||||
// toolStripComboBox1
|
||||
//
|
||||
this.toolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
@@ -463,13 +507,6 @@ namespace OpenRA.Editor
|
||||
this.toolStripStatusLabelMousePosition.Size = new System.Drawing.Size(22, 17);
|
||||
this.toolStripStatusLabelMousePosition.Text = "0,0";
|
||||
//
|
||||
// fixOpenAreasToolStripMenuItem
|
||||
//
|
||||
this.fixOpenAreasToolStripMenuItem.Name = "fixOpenAreasToolStripMenuItem";
|
||||
this.fixOpenAreasToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.fixOpenAreasToolStripMenuItem.Text = "&Fix Open Areas";
|
||||
this.fixOpenAreasToolStripMenuItem.Click += new System.EventHandler(this.FixOpenAreas);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -496,6 +533,7 @@ namespace OpenRA.Editor
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.tabPage3.ResumeLayout(false);
|
||||
this.splitContainer3.Panel1.ResumeLayout(false);
|
||||
this.splitContainer3.Panel1.PerformLayout();
|
||||
@@ -518,13 +556,11 @@ namespace OpenRA.Editor
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.FlowLayoutPanel tilePalette;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.FlowLayoutPanel actorPalette;
|
||||
private System.Windows.Forms.TabPage tabPage3;
|
||||
private System.Windows.Forms.FlowLayoutPanel resourcePalette;
|
||||
private System.Windows.Forms.FlowLayoutPanel resourcePalette;
|
||||
private Surface surface1;
|
||||
private System.Windows.Forms.PictureBox pmMiniMap;
|
||||
private System.Windows.Forms.PictureBox pmMiniMap;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog;
|
||||
private System.Windows.Forms.SplitContainer splitContainer3;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelMousePosition;
|
||||
@@ -550,7 +586,12 @@ namespace OpenRA.Editor
|
||||
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
|
||||
private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
|
||||
private System.Windows.Forms.ToolStripMenuItem showActorNamesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem showGridToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fixOpenAreasToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem setupDefaultPlayersMenuItem;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.FlowLayoutPanel actorPalette;
|
||||
private System.Windows.Forms.ComboBox actorOwnerChooser;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
@@ -29,8 +30,8 @@ namespace OpenRA.Editor
|
||||
currentMod = args.FirstOrDefault() ?? "ra";
|
||||
|
||||
toolStripComboBox1.Items.AddRange(Mod.AllMods.Keys.ToArray());
|
||||
|
||||
toolStripComboBox1.SelectedIndexChanged += (_, e) =>
|
||||
|
||||
toolStripComboBox1.SelectedIndexChanged += (_, e) =>
|
||||
{
|
||||
tilePalette.SuspendLayout();
|
||||
actorPalette.SuspendLayout();
|
||||
@@ -44,19 +45,20 @@ namespace OpenRA.Editor
|
||||
surface1.Bind(null, null, null);
|
||||
pmMiniMap.Image = null;
|
||||
currentMod = toolStripComboBox1.SelectedItem as string;
|
||||
|
||||
|
||||
Text = "OpenRA Editor (mod:{0})".F(currentMod);
|
||||
Game.modData = new ModData(currentMod);
|
||||
FileSystem.LoadFromManifest(Game.modData.Manifest);
|
||||
Rules.LoadRules(Game.modData.Manifest, new Map());
|
||||
loadedMapName = null;
|
||||
};
|
||||
|
||||
|
||||
toolStripComboBox1.SelectedItem = currentMod;
|
||||
|
||||
|
||||
surface1.AfterChange += OnMapChanged;
|
||||
surface1.MousePositionChanged += s => toolStripStatusLabelMousePosition.Text = s;
|
||||
|
||||
surface1.ActorDoubleClicked += ActorDoubleClicked;
|
||||
|
||||
if (args.Length >= 2)
|
||||
LoadMap(args[1]);
|
||||
}
|
||||
@@ -67,7 +69,31 @@ namespace OpenRA.Editor
|
||||
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
|
||||
}
|
||||
|
||||
void ActorDoubleClicked(KeyValuePair<string,ActorReference> kv)
|
||||
{
|
||||
using( var apd = new ActorPropertiesDialog() )
|
||||
{
|
||||
var name = kv.Key;
|
||||
apd.AddRow("(Name)", apd.MakeEditorControl(typeof(string), () => name, v => name = (string)v));
|
||||
apd.AddRow("(Type)", apd.MakeEditorControl(typeof(string), () => kv.Value.Type, v => kv.Value.Type = (string)v));
|
||||
|
||||
var objSaved = kv.Value.Save();
|
||||
|
||||
// TODO: make this work properly
|
||||
foreach( var init in Rules.Info[kv.Value.Type].GetInitKeys() )
|
||||
apd.AddRow(init.First,
|
||||
apd.MakeEditorControl(init.Second,
|
||||
() => objSaved.NodesDict.ContainsKey( init.First ) ? objSaved.NodesDict[init.First].Value : null,
|
||||
_ => {}));
|
||||
|
||||
apd.ShowDialog();
|
||||
|
||||
// TODO: writeback
|
||||
}
|
||||
}
|
||||
|
||||
void MakeDirty() { dirty = true; }
|
||||
|
||||
string loadedMapName;
|
||||
string currentMod = "ra";
|
||||
TileSet tileset;
|
||||
@@ -114,7 +140,6 @@ namespace OpenRA.Editor
|
||||
tileset.LoadTiles();
|
||||
var palette = new Palette(FileSystem.Open(tileset.Palette), true);
|
||||
|
||||
|
||||
surface1.Bind(map, tileset, palette);
|
||||
// construct the palette of tiles
|
||||
var palettes = new[] { tilePalette, actorPalette, resourcePalette };
|
||||
@@ -123,7 +148,7 @@ namespace OpenRA.Editor
|
||||
{
|
||||
try
|
||||
{
|
||||
var bitmap = RenderUtils.RenderTemplate(tileset, (ushort)t.Key, palette);
|
||||
var bitmap = tileset.RenderTemplate((ushort)t.Key, palette);
|
||||
var ibox = new PictureBox
|
||||
{
|
||||
Image = bitmap,
|
||||
@@ -158,9 +183,9 @@ namespace OpenRA.Editor
|
||||
|
||||
var etf = info.Traits.GetOrDefault<EditorTilesetFilterInfo>();
|
||||
if (etf != null && etf.ExcludeTilesets != null
|
||||
&& etf.ExcludeTilesets.Contains(tileset.Id)) continue;
|
||||
&& etf.ExcludeTilesets.Contains(tileset.Id)) continue;
|
||||
if (etf != null && etf.RequireTilesets != null
|
||||
&& !etf.RequireTilesets.Contains(tileset.Id)) continue;
|
||||
&& !etf.RequireTilesets.Contains(tileset.Id)) continue;
|
||||
|
||||
var template = RenderUtils.RenderActor(info, tileset, palette);
|
||||
var ibox = new PictureBox
|
||||
@@ -172,7 +197,6 @@ namespace OpenRA.Editor
|
||||
BorderStyle = BorderStyle.FixedSingle
|
||||
};
|
||||
|
||||
|
||||
ibox.Click += (_, e) => surface1.SetTool(new ActorTool(template));
|
||||
|
||||
actorPalette.Controls.Add(ibox);
|
||||
@@ -235,6 +259,16 @@ namespace OpenRA.Editor
|
||||
saveToolStripMenuItem.Enabled = true;
|
||||
saveAsToolStripMenuItem.Enabled = true;
|
||||
mnuMinimapToPNG.Enabled = true; // todo: what is this VB naming bullshit doing here?
|
||||
|
||||
PopulateActorOwnerChooser();
|
||||
}
|
||||
|
||||
void PopulateActorOwnerChooser()
|
||||
{
|
||||
actorOwnerChooser.Items.Clear();
|
||||
actorOwnerChooser.Items.AddRange(surface1.Map.Players.Values.ToArray());
|
||||
actorOwnerChooser.SelectedIndex = 0;
|
||||
surface1.NewActorOwner = (actorOwnerChooser.SelectedItem as PlayerReference).Name;
|
||||
}
|
||||
|
||||
void ResizeClicked(object sender, EventArgs e)
|
||||
@@ -366,7 +400,7 @@ namespace OpenRA.Editor
|
||||
|
||||
void ImportLegacyMapClicked(object sender, EventArgs e)
|
||||
{
|
||||
using (var ofd = new OpenFileDialog { RestoreDirectory = true,
|
||||
using (var ofd = new OpenFileDialog { RestoreDirectory = true,
|
||||
Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" })
|
||||
if (DialogResult.OK == ofd.ShowDialog())
|
||||
{
|
||||
@@ -385,7 +419,7 @@ namespace OpenRA.Editor
|
||||
eld.ShowDialog();
|
||||
|
||||
map.MakeDefaultPlayers();
|
||||
|
||||
|
||||
map.Save(savePath);
|
||||
LoadMap(savePath);
|
||||
loadedMapName = null; /* editor needs to think this hasnt been saved */
|
||||
@@ -410,11 +444,15 @@ namespace OpenRA.Editor
|
||||
|
||||
void ExportMinimap(object sender, EventArgs e)
|
||||
{
|
||||
saveFileDialog.InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps");
|
||||
saveFileDialog.FileName = Path.ChangeExtension(loadedMapName, ".png");
|
||||
|
||||
if (DialogResult.OK == saveFileDialog.ShowDialog())
|
||||
pmMiniMap.Image.Save(saveFileDialog.FileName);
|
||||
using( var sfd = new SaveFileDialog() {
|
||||
InitialDirectory = Path.Combine(Environment.CurrentDirectory, "maps"),
|
||||
DefaultExt = "*.png",
|
||||
Filter = "PNG Image (*.png)|*.png",
|
||||
Title = "Export Minimap to PNG",
|
||||
FileName = Path.ChangeExtension(loadedMapName, ".png"),
|
||||
RestoreDirectory = true } )
|
||||
if (DialogResult.OK == sfd.ShowDialog())
|
||||
pmMiniMap.Image.Save(sfd.FileName);
|
||||
}
|
||||
|
||||
void ShowActorNamesClicked(object sender, EventArgs e)
|
||||
@@ -423,6 +461,13 @@ namespace OpenRA.Editor
|
||||
surface1.ShowActorNames = showActorNamesToolStripMenuItem.Checked;
|
||||
}
|
||||
|
||||
void ShowGridClicked(object sender, EventArgs e)
|
||||
{
|
||||
showGridToolStripMenuItem.Checked ^= true;
|
||||
surface1.ShowGrid = showGridToolStripMenuItem.Checked;
|
||||
surface1.Chunks.Clear();
|
||||
}
|
||||
|
||||
void FixOpenAreas(object sender, EventArgs e)
|
||||
{
|
||||
dirty = true;
|
||||
@@ -433,8 +478,8 @@ namespace OpenRA.Editor
|
||||
{
|
||||
var tr = surface1.Map.MapTiles.Value[i, j];
|
||||
if (tr.type == 0xff || tr.type == 0xffff || tr.type == 1 || tr.type == 2)
|
||||
tr.index = (byte)r.Next(0,
|
||||
Rules.TileSets[surface1.Map.Tileset].Tiles[tr.type].TileBitmapBytes.Count);
|
||||
tr.index = (byte)r.Next(0,
|
||||
Rules.TileSets[surface1.Map.Tileset].Templates[tr.type].Data.TileBitmapBytes.Count);
|
||||
|
||||
surface1.Map.MapTiles.Value[i, j] = tr;
|
||||
}
|
||||
@@ -442,5 +487,40 @@ namespace OpenRA.Editor
|
||||
surface1.Chunks.Clear();
|
||||
surface1.Invalidate();
|
||||
}
|
||||
|
||||
void SetupDefaultPlayers(object sender, EventArgs e)
|
||||
{
|
||||
dirty = true;
|
||||
surface1.Map.MakeDefaultPlayers();
|
||||
|
||||
surface1.Chunks.Clear();
|
||||
surface1.Invalidate();
|
||||
|
||||
PopulateActorOwnerChooser();
|
||||
}
|
||||
|
||||
void onDrawPlayerItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
// color block
|
||||
var player = e.Index >= 0 ? (PlayerReference)(sender as ComboBox).Items[e.Index] : null;
|
||||
|
||||
e.DrawBackground();
|
||||
e.DrawFocusRectangle();
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
var color = player.ColorRamp.GetColor(0);
|
||||
using( var brush = new SolidBrush(color) )
|
||||
e.Graphics.FillRectangle( brush, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height + 6, e.Bounds.Height - 4 );
|
||||
using( var foreBrush = new SolidBrush(e.ForeColor) )
|
||||
e.Graphics.DrawString( player.Name, e.Font, foreBrush, e.Bounds.Left + e.Bounds.Height + 12, e.Bounds.Top );
|
||||
}
|
||||
|
||||
void onSelectOwner(object sender, EventArgs e)
|
||||
{
|
||||
var player = actorOwnerChooser.SelectedItem as PlayerReference;
|
||||
surface1.NewActorOwner = player.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -39,12 +39,12 @@ namespace OpenRA.Editor
|
||||
{ "gold02", new Pair<byte,byte>(1,1) },
|
||||
{ "gold03", new Pair<byte,byte>(1,2) },
|
||||
{ "gold04", new Pair<byte,byte>(1,3) },
|
||||
|
||||
|
||||
{ "gem01", new Pair<byte,byte>(2,0) },
|
||||
{ "gem02", new Pair<byte,byte>(2,1) },
|
||||
{ "gem03", new Pair<byte,byte>(2,2) },
|
||||
{ "gem04", new Pair<byte,byte>(2,3) },
|
||||
|
||||
|
||||
// cnc tiberium
|
||||
{ "ti1", new Pair<byte,byte>(1,0) },
|
||||
{ "ti2", new Pair<byte,byte>(1,1) },
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Editor
|
||||
{"brik","brik"},
|
||||
{"fenc","fenc"},
|
||||
{"wood","wood"},
|
||||
|
||||
|
||||
// Fields
|
||||
{"v12","v12"},
|
||||
{"v13","v13"},
|
||||
@@ -76,12 +76,12 @@ namespace OpenRA.Editor
|
||||
{"v16","v16"},
|
||||
{"v17","v17"},
|
||||
{"v18","v18"},
|
||||
|
||||
|
||||
// Crates
|
||||
// {"wcrate","crate"},
|
||||
// {"scrate","crate"},
|
||||
};
|
||||
|
||||
|
||||
// todo: fix this -- will have bitrotted pretty badly.
|
||||
static Dictionary<string,Pair<Color,Color>> namedColorMapping = new Dictionary<string, Pair<Color, Color>>()
|
||||
{
|
||||
@@ -96,13 +96,13 @@ namespace OpenRA.Editor
|
||||
{"white",Pair.New(Color.FromArgb(255,255,255),Color.FromArgb(75,75,75))},
|
||||
{"black",Pair.New(Color.FromArgb(80,80,80),Color.FromArgb(5,5,5))},
|
||||
};
|
||||
|
||||
|
||||
int MapSize;
|
||||
int ActorCount = 0;
|
||||
Map Map = new Map();
|
||||
List<string> Players = new List<string>();
|
||||
Action<string> errorHandler;
|
||||
|
||||
|
||||
LegacyMapImporter(string filename, Action<string> errorHandler)
|
||||
{
|
||||
this.errorHandler = errorHandler;
|
||||
@@ -116,10 +116,10 @@ namespace OpenRA.Editor
|
||||
}
|
||||
|
||||
enum IniMapFormat { RedAlert = 3, /* otherwise, cnc (2 variants exist, we don't care to differentiate) */ };
|
||||
|
||||
|
||||
public void ConvertIniMap(string iniFile)
|
||||
{
|
||||
|
||||
|
||||
var file = new IniFile(FileSystem.Open(iniFile));
|
||||
var basic = file.GetSection("Basic");
|
||||
var map = file.GetSection("Map");
|
||||
@@ -137,12 +137,12 @@ namespace OpenRA.Editor
|
||||
Map.MapSize.Y = MapSize;
|
||||
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height);
|
||||
Map.Selectable = true;
|
||||
|
||||
|
||||
Map.Smudges = Lazy.New(() => new List<SmudgeReference>());
|
||||
Map.Actors = Lazy.New(() => new Dictionary<string, ActorReference>());
|
||||
Map.MapResources = Lazy.New(() => new TileReference<byte, byte>[MapSize, MapSize]);
|
||||
Map.MapTiles = Lazy.New(() => new TileReference<ushort, byte>[MapSize, MapSize]);
|
||||
|
||||
|
||||
if (legacyMapFormat == IniMapFormat.RedAlert)
|
||||
{
|
||||
UnpackRATileData(ReadPackedSection(file.GetSection("MapPack")));
|
||||
@@ -155,22 +155,22 @@ namespace OpenRA.Editor
|
||||
ReadCncOverlay(file);
|
||||
ReadCncTrees(file);
|
||||
}
|
||||
|
||||
|
||||
LoadActors(file, "STRUCTURES");
|
||||
LoadActors(file, "UNITS");
|
||||
LoadActors(file, "INFANTRY");
|
||||
LoadSmudges(file, "SMUDGE");
|
||||
|
||||
|
||||
foreach (var p in Players)
|
||||
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert));
|
||||
|
||||
|
||||
var wps = file.GetSection("Waypoints")
|
||||
.Where(kv => int.Parse(kv.Value) > 0)
|
||||
.Select(kv => Pair.New(int.Parse(kv.Key),
|
||||
LocationFromMapOffset(int.Parse(kv.Value), MapSize)))
|
||||
.ToArray();
|
||||
|
||||
|
||||
|
||||
|
||||
// Add waypoint actors
|
||||
foreach( var kv in wps )
|
||||
{
|
||||
@@ -179,7 +179,7 @@ namespace OpenRA.Editor
|
||||
a.Add(new OwnerInit("Neutral"));
|
||||
Map.Actors.Value.Add("spawn" + kv.First, a);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int2 LocationFromMapOffset(int offset, int mapSize)
|
||||
@@ -243,7 +243,7 @@ namespace OpenRA.Editor
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void UnpackRATileData(MemoryStream ms)
|
||||
{
|
||||
for (int i = 0; i < MapSize; i++)
|
||||
@@ -274,10 +274,10 @@ namespace OpenRA.Editor
|
||||
|
||||
if (o != 255 && overlayActorMapping.ContainsKey(raOverlayNames[o]))
|
||||
Map.Actors.Value.Add("Actor" + ActorCount++,
|
||||
new ActorReference(overlayActorMapping[raOverlayNames[o]])
|
||||
{
|
||||
new ActorReference(overlayActorMapping[raOverlayNames[o]])
|
||||
{
|
||||
new LocationInit( new int2(i, j) ),
|
||||
new OwnerInit( "Neutral" )
|
||||
new OwnerInit( "Neutral" )
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace OpenRA.Editor
|
||||
foreach (KeyValuePair<string, string> kv in terrain)
|
||||
{
|
||||
var loc = int.Parse(kv.Key);
|
||||
Map.Actors.Value.Add("Actor" + ActorCount++,
|
||||
Map.Actors.Value.Add("Actor" + ActorCount++,
|
||||
new ActorReference(kv.Value.ToLowerInvariant())
|
||||
{
|
||||
new LocationInit(new int2(loc % MapSize, loc / MapSize)),
|
||||
@@ -313,7 +313,7 @@ namespace OpenRA.Editor
|
||||
Map.MapTiles.Value[i, j].index = ReadByte(ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReadCncOverlay(IniFile file)
|
||||
{
|
||||
IniSection overlay = file.GetSection("OVERLAY", true);
|
||||
@@ -332,7 +332,7 @@ namespace OpenRA.Editor
|
||||
Map.MapResources.Value[cell.X, cell.Y] = new TileReference<byte, byte>(res.First, res.Second);
|
||||
|
||||
if (overlayActorMapping.ContainsKey(kv.Value.ToLower()))
|
||||
Map.Actors.Value.Add("Actor" + ActorCount++,
|
||||
Map.Actors.Value.Add("Actor" + ActorCount++,
|
||||
new ActorReference(overlayActorMapping[kv.Value.ToLower()])
|
||||
{
|
||||
new LocationInit(cell),
|
||||
@@ -340,7 +340,7 @@ namespace OpenRA.Editor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReadCncTrees(IniFile file)
|
||||
{
|
||||
IniSection terrain = file.GetSection("TERRAIN", true);
|
||||
@@ -401,7 +401,7 @@ namespace OpenRA.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadSmudges(IniFile file, string section)
|
||||
{
|
||||
foreach (var s in file.GetSection(section, true))
|
||||
@@ -412,14 +412,14 @@ namespace OpenRA.Editor
|
||||
Map.Smudges.Value.Add(new SmudgeReference(parts[0].ToLowerInvariant(), new int2(loc % MapSize, loc / MapSize), int.Parse(parts[2])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadPlayer(IniFile file, string section, bool isRA)
|
||||
{
|
||||
{
|
||||
var c = section == "BadGuy" ? "red" :
|
||||
isRA ? "blue" : "gold";
|
||||
|
||||
|
||||
var color = namedColorMapping[c];
|
||||
|
||||
|
||||
var pr = new PlayerReference
|
||||
{
|
||||
Name = section,
|
||||
@@ -427,12 +427,12 @@ namespace OpenRA.Editor
|
||||
NonCombatant = section == "Neutral",
|
||||
Race = isRA ? (section == "BadGuy" ? "soviet" : "allies") : (section == "BadGuy" ? "nod" : "gdi"),
|
||||
ColorRamp = new ColorRamp(
|
||||
(byte)((color.First.GetHue() / 360.0f) * 255),
|
||||
(byte)(color.First.GetSaturation() * 255),
|
||||
(byte)(color.First.GetBrightness() * 255),
|
||||
(byte)(color.Second.GetBrightness() * 255))
|
||||
(byte)((color.First.GetHue() / 360.0f) * 255),
|
||||
(byte)(color.First.GetSaturation() * 255),
|
||||
(byte)(color.First.GetBrightness() * 255),
|
||||
(byte)(color.Second.GetBrightness() * 255))
|
||||
};
|
||||
|
||||
|
||||
var Neutral = new [] {"Neutral"};
|
||||
foreach (var s in file.GetSection(section, true))
|
||||
{
|
||||
@@ -448,7 +448,7 @@ namespace OpenRA.Editor
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Map.Players.Add(section, pr);
|
||||
}
|
||||
|
||||
|
||||
212
OpenRA.Editor/MapSelect.Designer.cs
generated
212
OpenRA.Editor/MapSelect.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -10,33 +10,33 @@
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
partial class MapSelect
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class MapSelect
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
/// <param name="disposing">TODO</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
/// <param name="disposing">TODO</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором форм Windows
|
||||
#region Код, автоматически созданный конструктором форм Windows
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MapSelect));
|
||||
this.MapList = new System.Windows.Forms.ListView();
|
||||
@@ -70,12 +70,12 @@ namespace OpenRA.Editor
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
//
|
||||
// MapList
|
||||
//
|
||||
//
|
||||
this.MapList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.MapList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colMapName});
|
||||
this.colMapName});
|
||||
this.MapList.FullRowSelect = true;
|
||||
this.MapList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.MapList.LargeImageList = this.MapIconsList;
|
||||
@@ -89,20 +89,20 @@ namespace OpenRA.Editor
|
||||
this.MapList.UseCompatibleStateImageBehavior = false;
|
||||
this.MapList.View = System.Windows.Forms.View.Details;
|
||||
this.MapList.SelectedIndexChanged += new System.EventHandler(this.MapList_SelectedIndexChanged);
|
||||
//
|
||||
//
|
||||
// colMapName
|
||||
//
|
||||
//
|
||||
this.colMapName.Text = "Map name";
|
||||
this.colMapName.Width = 240;
|
||||
//
|
||||
//
|
||||
// MapIconsList
|
||||
//
|
||||
//
|
||||
this.MapIconsList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
||||
this.MapIconsList.ImageSize = new System.Drawing.Size(24, 24);
|
||||
this.MapIconsList.TransparentColor = System.Drawing.Color.Transparent;
|
||||
//
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(407, 35);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
@@ -110,9 +110,9 @@ namespace OpenRA.Editor
|
||||
this.btnCancel.TabIndex = 3;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
//
|
||||
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOk.Location = new System.Drawing.Point(326, 35);
|
||||
this.btnOk.Name = "btnOk";
|
||||
@@ -120,9 +120,9 @@ namespace OpenRA.Editor
|
||||
this.btnOk.TabIndex = 2;
|
||||
this.btnOk.Text = "Open";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// lblNew
|
||||
//
|
||||
//
|
||||
this.lblNew.AutoSize = true;
|
||||
this.lblNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.lblNew.Location = new System.Drawing.Point(12, 40);
|
||||
@@ -130,18 +130,18 @@ namespace OpenRA.Editor
|
||||
this.lblNew.Size = new System.Drawing.Size(69, 13);
|
||||
this.lblNew.TabIndex = 3;
|
||||
this.lblNew.Text = "Map name:";
|
||||
//
|
||||
//
|
||||
// txtNew
|
||||
//
|
||||
//
|
||||
this.txtNew.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.txtNew.Location = new System.Drawing.Point(88, 37);
|
||||
this.txtNew.Name = "txtNew";
|
||||
this.txtNew.ReadOnly = true;
|
||||
this.txtNew.Size = new System.Drawing.Size(232, 20);
|
||||
this.txtNew.TabIndex = 1;
|
||||
//
|
||||
//
|
||||
// pbMinimap
|
||||
//
|
||||
//
|
||||
this.pbMinimap.BackColor = System.Drawing.Color.Black;
|
||||
this.pbMinimap.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.pbMinimap.Location = new System.Drawing.Point(32, 25);
|
||||
@@ -150,9 +150,9 @@ namespace OpenRA.Editor
|
||||
this.pbMinimap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.pbMinimap.TabIndex = 5;
|
||||
this.pbMinimap.TabStop = false;
|
||||
//
|
||||
//
|
||||
// pnlBottom
|
||||
//
|
||||
//
|
||||
this.pnlBottom.Controls.Add(this.pictureBox1);
|
||||
this.pnlBottom.Controls.Add(this.txtPathOut);
|
||||
this.pnlBottom.Controls.Add(this.lblPathOut);
|
||||
@@ -167,9 +167,9 @@ namespace OpenRA.Editor
|
||||
this.pnlBottom.Name = "pnlBottom";
|
||||
this.pnlBottom.Size = new System.Drawing.Size(494, 70);
|
||||
this.pnlBottom.TabIndex = 6;
|
||||
//
|
||||
//
|
||||
// txtPathOut
|
||||
//
|
||||
//
|
||||
this.txtPathOut.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.txtPathOut.Location = new System.Drawing.Point(55, 10);
|
||||
this.txtPathOut.Name = "txtPathOut";
|
||||
@@ -177,17 +177,17 @@ namespace OpenRA.Editor
|
||||
this.txtPathOut.Size = new System.Drawing.Size(265, 20);
|
||||
this.txtPathOut.TabIndex = 0;
|
||||
this.txtPathOut.TextChanged += new System.EventHandler(this.txtPathOut_TextChanged);
|
||||
//
|
||||
//
|
||||
// lblPathOut
|
||||
//
|
||||
//
|
||||
this.lblPathOut.AutoSize = true;
|
||||
this.lblPathOut.Location = new System.Drawing.Point(55, 13);
|
||||
this.lblPathOut.Name = "lblPathOut";
|
||||
this.lblPathOut.Size = new System.Drawing.Size(0, 13);
|
||||
this.lblPathOut.TabIndex = 6;
|
||||
//
|
||||
//
|
||||
// lblPath
|
||||
//
|
||||
//
|
||||
this.lblPath.AutoSize = true;
|
||||
this.lblPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.lblPath.Location = new System.Drawing.Point(12, 13);
|
||||
@@ -195,20 +195,20 @@ namespace OpenRA.Editor
|
||||
this.lblPath.Size = new System.Drawing.Size(37, 13);
|
||||
this.lblPath.TabIndex = 5;
|
||||
this.lblPath.Text = "Path:";
|
||||
//
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lblMapList);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.MapList);
|
||||
//
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.txtDesc);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.lblDesc);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.txtTheater);
|
||||
@@ -222,90 +222,90 @@ namespace OpenRA.Editor
|
||||
this.splitContainer1.Size = new System.Drawing.Size(494, 332);
|
||||
this.splitContainer1.SplitterDistance = 300;
|
||||
this.splitContainer1.TabIndex = 7;
|
||||
//
|
||||
//
|
||||
// lblMapList
|
||||
//
|
||||
//
|
||||
this.lblMapList.AutoSize = true;
|
||||
this.lblMapList.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblMapList.Name = "lblMapList";
|
||||
this.lblMapList.Size = new System.Drawing.Size(81, 13);
|
||||
this.lblMapList.TabIndex = 1;
|
||||
this.lblMapList.Text = "Available maps:";
|
||||
//
|
||||
//
|
||||
// txtDesc
|
||||
//
|
||||
//
|
||||
this.txtDesc.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.txtDesc.Location = new System.Drawing.Point(16, 289);
|
||||
this.txtDesc.Name = "txtDesc";
|
||||
this.txtDesc.ReadOnly = true;
|
||||
this.txtDesc.Size = new System.Drawing.Size(162, 20);
|
||||
this.txtDesc.TabIndex = 14;
|
||||
//
|
||||
//
|
||||
// lblDesc
|
||||
//
|
||||
//
|
||||
this.lblDesc.AutoSize = true;
|
||||
this.lblDesc.Location = new System.Drawing.Point(13, 273);
|
||||
this.lblDesc.Name = "lblDesc";
|
||||
this.lblDesc.Size = new System.Drawing.Size(63, 13);
|
||||
this.lblDesc.TabIndex = 13;
|
||||
this.lblDesc.Text = "Description:";
|
||||
//
|
||||
//
|
||||
// txtTheater
|
||||
//
|
||||
//
|
||||
this.txtTheater.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.txtTheater.Location = new System.Drawing.Point(16, 252);
|
||||
this.txtTheater.Name = "txtTheater";
|
||||
this.txtTheater.ReadOnly = true;
|
||||
this.txtTheater.Size = new System.Drawing.Size(162, 20);
|
||||
this.txtTheater.TabIndex = 12;
|
||||
//
|
||||
//
|
||||
// lblTheater
|
||||
//
|
||||
//
|
||||
this.lblTheater.AutoSize = true;
|
||||
this.lblTheater.Location = new System.Drawing.Point(13, 236);
|
||||
this.lblTheater.Name = "lblTheater";
|
||||
this.lblTheater.Size = new System.Drawing.Size(47, 13);
|
||||
this.lblTheater.TabIndex = 11;
|
||||
this.lblTheater.Text = "Tileset:";
|
||||
//
|
||||
//
|
||||
// txtAuthor
|
||||
//
|
||||
//
|
||||
this.txtAuthor.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.txtAuthor.Location = new System.Drawing.Point(16, 214);
|
||||
this.txtAuthor.Name = "txtAuthor";
|
||||
this.txtAuthor.ReadOnly = true;
|
||||
this.txtAuthor.Size = new System.Drawing.Size(162, 20);
|
||||
this.txtAuthor.TabIndex = 10;
|
||||
//
|
||||
//
|
||||
// lblAuthor
|
||||
//
|
||||
//
|
||||
this.lblAuthor.AutoSize = true;
|
||||
this.lblAuthor.Location = new System.Drawing.Point(13, 198);
|
||||
this.lblAuthor.Name = "lblAuthor";
|
||||
this.lblAuthor.Size = new System.Drawing.Size(41, 13);
|
||||
this.lblAuthor.TabIndex = 9;
|
||||
this.lblAuthor.Text = "Author:";
|
||||
//
|
||||
//
|
||||
// txtTitle
|
||||
//
|
||||
//
|
||||
this.txtTitle.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.txtTitle.Location = new System.Drawing.Point(16, 177);
|
||||
this.txtTitle.Name = "txtTitle";
|
||||
this.txtTitle.ReadOnly = true;
|
||||
this.txtTitle.Size = new System.Drawing.Size(162, 20);
|
||||
this.txtTitle.TabIndex = 8;
|
||||
//
|
||||
//
|
||||
// lblMapName
|
||||
//
|
||||
//
|
||||
this.lblMapName.AutoSize = true;
|
||||
this.lblMapName.Location = new System.Drawing.Point(13, 161);
|
||||
this.lblMapName.Name = "lblMapName";
|
||||
this.lblMapName.Size = new System.Drawing.Size(30, 13);
|
||||
this.lblMapName.TabIndex = 7;
|
||||
this.lblMapName.Text = "Title:";
|
||||
//
|
||||
//
|
||||
// lblMinimap
|
||||
//
|
||||
//
|
||||
this.lblMinimap.AutoSize = true;
|
||||
this.lblMinimap.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.lblMinimap.Location = new System.Drawing.Point(29, 9);
|
||||
@@ -313,9 +313,9 @@ namespace OpenRA.Editor
|
||||
this.lblMinimap.Size = new System.Drawing.Size(71, 13);
|
||||
this.lblMinimap.TabIndex = 6;
|
||||
this.lblMinimap.Text = "Map preview:";
|
||||
//
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
//
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(336, -9);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
@@ -323,9 +323,9 @@ namespace OpenRA.Editor
|
||||
this.pictureBox1.TabIndex = 7;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.Visible = false;
|
||||
//
|
||||
//
|
||||
// MapSelect
|
||||
//
|
||||
//
|
||||
this.AcceptButton = this.btnOk;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@@ -353,33 +353,33 @@ namespace OpenRA.Editor
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public System.Windows.Forms.ListView MapList;
|
||||
public System.Windows.Forms.Button btnCancel;
|
||||
public System.Windows.Forms.Button btnOk;
|
||||
public System.Windows.Forms.Label lblNew;
|
||||
public System.Windows.Forms.TextBox txtNew;
|
||||
public System.Windows.Forms.ColumnHeader colMapName;
|
||||
public System.Windows.Forms.ImageList MapIconsList;
|
||||
public System.Windows.Forms.PictureBox pbMinimap;
|
||||
public System.Windows.Forms.Panel pnlBottom;
|
||||
public System.Windows.Forms.SplitContainer splitContainer1;
|
||||
public System.Windows.Forms.Label lblMinimap;
|
||||
public System.Windows.Forms.TextBox txtTheater;
|
||||
public System.Windows.Forms.Label lblTheater;
|
||||
public System.Windows.Forms.TextBox txtAuthor;
|
||||
public System.Windows.Forms.Label lblAuthor;
|
||||
public System.Windows.Forms.TextBox txtTitle;
|
||||
public System.Windows.Forms.Label lblMapName;
|
||||
public System.Windows.Forms.TextBox txtDesc;
|
||||
public System.Windows.Forms.Label lblDesc;
|
||||
public System.Windows.Forms.Label lblMapList;
|
||||
public System.Windows.Forms.Label lblPathOut;
|
||||
public System.Windows.Forms.Label lblPath;
|
||||
public System.Windows.Forms.TextBox txtPathOut;
|
||||
public System.Windows.Forms.ListView MapList;
|
||||
public System.Windows.Forms.Button btnCancel;
|
||||
public System.Windows.Forms.Button btnOk;
|
||||
public System.Windows.Forms.Label lblNew;
|
||||
public System.Windows.Forms.TextBox txtNew;
|
||||
public System.Windows.Forms.ColumnHeader colMapName;
|
||||
public System.Windows.Forms.ImageList MapIconsList;
|
||||
public System.Windows.Forms.PictureBox pbMinimap;
|
||||
public System.Windows.Forms.Panel pnlBottom;
|
||||
public System.Windows.Forms.SplitContainer splitContainer1;
|
||||
public System.Windows.Forms.Label lblMinimap;
|
||||
public System.Windows.Forms.TextBox txtTheater;
|
||||
public System.Windows.Forms.Label lblTheater;
|
||||
public System.Windows.Forms.TextBox txtAuthor;
|
||||
public System.Windows.Forms.Label lblAuthor;
|
||||
public System.Windows.Forms.TextBox txtTitle;
|
||||
public System.Windows.Forms.Label lblMapName;
|
||||
public System.Windows.Forms.TextBox txtDesc;
|
||||
public System.Windows.Forms.Label lblDesc;
|
||||
public System.Windows.Forms.Label lblMapList;
|
||||
public System.Windows.Forms.Label lblPathOut;
|
||||
public System.Windows.Forms.Label lblPath;
|
||||
public System.Windows.Forms.TextBox txtPathOut;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -10,75 +10,73 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
public partial class MapSelect : Form
|
||||
{
|
||||
public string MapFolderPath;
|
||||
public partial class MapSelect : Form
|
||||
{
|
||||
public string MapFolderPath;
|
||||
|
||||
public MapSelect(string currentMod)
|
||||
{
|
||||
MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" }
|
||||
public MapSelect(string currentMod)
|
||||
{
|
||||
MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" }
|
||||
.Aggregate(Path.Combine);
|
||||
|
||||
|
||||
InitializeComponent();
|
||||
MapIconsList.Images.Add(pictureBox1.Image);
|
||||
}
|
||||
}
|
||||
|
||||
void MapSelect_Load(object sender, EventArgs e)
|
||||
{
|
||||
MapList.Items.Clear();
|
||||
txtPathOut.Text = MapFolderPath;
|
||||
|
||||
foreach (var map in ModData.FindMapsIn(MapFolderPath))
|
||||
{
|
||||
ListViewItem map1 = new ListViewItem();
|
||||
void MapSelect_Load(object sender, EventArgs e)
|
||||
{
|
||||
MapList.Items.Clear();
|
||||
txtPathOut.Text = MapFolderPath;
|
||||
|
||||
foreach (var map in ModData.FindMapsIn(MapFolderPath))
|
||||
{
|
||||
ListViewItem map1 = new ListViewItem();
|
||||
map1.Tag = map;
|
||||
map1.Text = Path.GetFileNameWithoutExtension(map);
|
||||
map1.ImageIndex = 0;
|
||||
MapList.Items.Add(map1);
|
||||
}
|
||||
|
||||
map1.ImageIndex = 0;
|
||||
MapList.Items.Add(map1);
|
||||
}
|
||||
|
||||
// hack
|
||||
if (txtNew.Text != "unnamed")
|
||||
MapList.Items[0].Selected = true;
|
||||
}
|
||||
MapList.Items[0].Selected = true;
|
||||
}
|
||||
|
||||
void MapList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (MapList.SelectedItems.Count == 1)
|
||||
{
|
||||
txtNew.Text = MapList.SelectedItems[0].Text;
|
||||
void MapList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (MapList.SelectedItems.Count == 1)
|
||||
{
|
||||
txtNew.Text = MapList.SelectedItems[0].Text;
|
||||
txtNew.Tag = MapList.SelectedItems[0].Tag;
|
||||
|
||||
var map = new Map(txtNew.Tag as string);
|
||||
txtTitle.Text = map.Title;
|
||||
txtAuthor.Text = map.Author;
|
||||
txtTheater.Text = map.Tileset;
|
||||
txtDesc.Text = map.Description;
|
||||
txtTitle.Text = map.Title;
|
||||
txtAuthor.Text = map.Author;
|
||||
txtTheater.Text = map.Tileset;
|
||||
txtDesc.Text = map.Description;
|
||||
pbMinimap.Image = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true));
|
||||
}
|
||||
catch (Exception ed)
|
||||
{
|
||||
Console.WriteLine("No map preview image found: {0}", ed.ToString());
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ed)
|
||||
{
|
||||
Console.WriteLine("No map preview image found: {0}", ed.ToString());
|
||||
}
|
||||
finally { }
|
||||
}
|
||||
}
|
||||
|
||||
void txtPathOut_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
MapFolderPath = txtPathOut.Text;
|
||||
}
|
||||
|
||||
}
|
||||
void txtPathOut_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
MapFolderPath = txtPathOut.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
170
OpenRA.Editor/NewMapDialog.Designer.cs
generated
170
OpenRA.Editor/NewMapDialog.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -58,9 +58,9 @@ namespace OpenRA.Editor
|
||||
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.width)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
//
|
||||
// button2
|
||||
//
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Location = new System.Drawing.Point(229, 160);
|
||||
this.button2.Name = "button2";
|
||||
@@ -68,9 +68,9 @@ namespace OpenRA.Editor
|
||||
this.button2.TabIndex = 7;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// button1
|
||||
//
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(310, 160);
|
||||
this.button1.Name = "button1";
|
||||
@@ -78,172 +78,172 @@ namespace OpenRA.Editor
|
||||
this.button1.TabIndex = 8;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// label3
|
||||
//
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(31, 77);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(107, 13);
|
||||
this.label3.TabIndex = 9;
|
||||
this.label3.Text = "Cordon Right/Bottom";
|
||||
//
|
||||
//
|
||||
// label2
|
||||
//
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(31, 51);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(86, 13);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "Cordon Left/Top";
|
||||
//
|
||||
//
|
||||
// label1
|
||||
//
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(31, 25);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "Size";
|
||||
//
|
||||
//
|
||||
// cordonBottom
|
||||
//
|
||||
//
|
||||
this.cordonBottom.Location = new System.Drawing.Point(280, 75);
|
||||
this.cordonBottom.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonBottom.Name = "cordonBottom";
|
||||
this.cordonBottom.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonBottom.TabIndex = 5;
|
||||
this.cordonBottom.Value = new decimal(new int[] {
|
||||
112,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
112,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonBottom.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// cordonTop
|
||||
//
|
||||
//
|
||||
this.cordonTop.Location = new System.Drawing.Point(280, 49);
|
||||
this.cordonTop.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonTop.Name = "cordonTop";
|
||||
this.cordonTop.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonTop.TabIndex = 3;
|
||||
this.cordonTop.Value = new decimal(new int[] {
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonTop.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// cordonRight
|
||||
//
|
||||
//
|
||||
this.cordonRight.Location = new System.Drawing.Point(169, 75);
|
||||
this.cordonRight.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonRight.Name = "cordonRight";
|
||||
this.cordonRight.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonRight.TabIndex = 4;
|
||||
this.cordonRight.Value = new decimal(new int[] {
|
||||
112,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
112,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonRight.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// cordonLeft
|
||||
//
|
||||
//
|
||||
this.cordonLeft.Location = new System.Drawing.Point(169, 49);
|
||||
this.cordonLeft.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonLeft.Name = "cordonLeft";
|
||||
this.cordonLeft.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonLeft.TabIndex = 2;
|
||||
this.cordonLeft.Value = new decimal(new int[] {
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonLeft.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// height
|
||||
//
|
||||
//
|
||||
this.height.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.height.Location = new System.Drawing.Point(280, 23);
|
||||
this.height.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.height.Name = "height";
|
||||
this.height.Size = new System.Drawing.Size(105, 20);
|
||||
this.height.TabIndex = 1;
|
||||
this.height.Value = new decimal(new int[] {
|
||||
128,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
128,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.height.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// width
|
||||
//
|
||||
//
|
||||
this.width.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.width.Location = new System.Drawing.Point(169, 23);
|
||||
this.width.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.width.Name = "width";
|
||||
this.width.Size = new System.Drawing.Size(105, 20);
|
||||
this.width.TabIndex = 0;
|
||||
this.width.Value = new decimal(new int[] {
|
||||
128,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
128,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.width.Enter += new System.EventHandler(this.SelectText);
|
||||
//
|
||||
//
|
||||
// label4
|
||||
//
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(31, 124);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(44, 13);
|
||||
this.label4.TabIndex = 14;
|
||||
this.label4.Text = "Tileset";
|
||||
//
|
||||
//
|
||||
// theater
|
||||
//
|
||||
//
|
||||
this.theater.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.theater.FormattingEnabled = true;
|
||||
this.theater.Location = new System.Drawing.Point(169, 121);
|
||||
this.theater.Name = "theater";
|
||||
this.theater.Size = new System.Drawing.Size(216, 21);
|
||||
this.theater.TabIndex = 6;
|
||||
//
|
||||
//
|
||||
// NewMapDialog
|
||||
//
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -53,6 +53,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActorPropertiesDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ActorPropertiesDialog.Designer.cs">
|
||||
<DependentUpon>ActorPropertiesDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ActorTemplate.cs" />
|
||||
<Compile Include="ActorTool.cs" />
|
||||
<Compile Include="BrushTool.cs" />
|
||||
@@ -90,6 +96,9 @@
|
||||
<DependentUpon>PropertiesDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="ActorPropertiesDialog.resx">
|
||||
<DependentUpon>ActorPropertiesDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -30,30 +30,30 @@ namespace OpenRA.Editor
|
||||
UpgradeMaps(args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Application.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
Application.Run(new Form1(args));
|
||||
}
|
||||
|
||||
|
||||
static void UpgradeMaps(string mod)
|
||||
{
|
||||
var MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", mod, "maps" }
|
||||
.Aggregate(Path.Combine);
|
||||
|
||||
|
||||
foreach (var path in ModData.FindMapsIn(MapFolderPath))
|
||||
{
|
||||
var map = new Map(path);
|
||||
{
|
||||
var map = new Map(path);
|
||||
// Touch the lazy bits to initialize them
|
||||
map.Actors.Force();
|
||||
map.Smudges.Force();
|
||||
map.MapTiles.Force();
|
||||
map.MapResources.Force();
|
||||
map.Actors.Force();
|
||||
map.Smudges.Force();
|
||||
map.MapTiles.Force();
|
||||
map.MapResources.Force();
|
||||
map.Save(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -12,7 +12,7 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// 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.Editor")]
|
||||
@@ -24,8 +24,8 @@ using System.Runtime.InteropServices;
|
||||
[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
|
||||
// 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)]
|
||||
|
||||
@@ -35,11 +35,11 @@ using System.Runtime.InteropServices;
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
|
||||
256
OpenRA.Editor/PropertiesDialog.Designer.cs
generated
256
OpenRA.Editor/PropertiesDialog.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -38,131 +38,131 @@ namespace OpenRA.Editor
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.title = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.desc = new System.Windows.Forms.TextBox();
|
||||
this.selectable = new System.Windows.Forms.CheckBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.author = new System.Windows.Forms.TextBox();
|
||||
this.useAsShellmap = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Location = new System.Drawing.Point(196, 193);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 14;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(277, 193);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 15;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 50);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||
this.label1.TabIndex = 16;
|
||||
this.label1.Text = "Title";
|
||||
//
|
||||
// title
|
||||
//
|
||||
this.title.Location = new System.Drawing.Point(66, 47);
|
||||
this.title.Name = "title";
|
||||
this.title.Size = new System.Drawing.Size(286, 20);
|
||||
this.title.TabIndex = 17;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 76);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(32, 13);
|
||||
this.label2.TabIndex = 16;
|
||||
this.label2.Text = "Desc";
|
||||
//
|
||||
// desc
|
||||
//
|
||||
this.desc.Location = new System.Drawing.Point(66, 73);
|
||||
this.desc.Name = "desc";
|
||||
this.desc.Size = new System.Drawing.Size(286, 20);
|
||||
this.desc.TabIndex = 17;
|
||||
//
|
||||
// selectable
|
||||
//
|
||||
this.selectable.AutoSize = true;
|
||||
this.selectable.Location = new System.Drawing.Point(118, 138);
|
||||
this.selectable.Name = "selectable";
|
||||
this.selectable.Size = new System.Drawing.Size(130, 17);
|
||||
this.selectable.TabIndex = 18;
|
||||
this.selectable.Text = "Show in Map Chooser";
|
||||
this.selectable.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 102);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(38, 13);
|
||||
this.label3.TabIndex = 16;
|
||||
this.label3.Text = "Author";
|
||||
//
|
||||
// author
|
||||
//
|
||||
this.author.Location = new System.Drawing.Point(66, 99);
|
||||
this.author.Name = "author";
|
||||
this.author.Size = new System.Drawing.Size(286, 20);
|
||||
this.author.TabIndex = 17;
|
||||
//
|
||||
// checkBox1
|
||||
//
|
||||
this.useAsShellmap.AutoSize = true;
|
||||
this.useAsShellmap.Location = new System.Drawing.Point(118, 161);
|
||||
this.useAsShellmap.Name = "checkBox1";
|
||||
this.useAsShellmap.Size = new System.Drawing.Size(105, 17);
|
||||
this.useAsShellmap.TabIndex = 18;
|
||||
this.useAsShellmap.Text = "Use as Shellmap";
|
||||
this.useAsShellmap.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// PropertiesDialog
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.button1;
|
||||
this.ClientSize = new System.Drawing.Size(370, 228);
|
||||
this.Controls.Add(this.useAsShellmap);
|
||||
this.Controls.Add(this.selectable);
|
||||
this.Controls.Add(this.author);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.desc);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.title);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Name = "PropertiesDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "PropertiesDialog";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.title = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.desc = new System.Windows.Forms.TextBox();
|
||||
this.selectable = new System.Windows.Forms.CheckBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.author = new System.Windows.Forms.TextBox();
|
||||
this.useAsShellmap = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Location = new System.Drawing.Point(196, 193);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 14;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(277, 193);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 15;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 50);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||
this.label1.TabIndex = 16;
|
||||
this.label1.Text = "Title";
|
||||
//
|
||||
// title
|
||||
//
|
||||
this.title.Location = new System.Drawing.Point(66, 47);
|
||||
this.title.Name = "title";
|
||||
this.title.Size = new System.Drawing.Size(286, 20);
|
||||
this.title.TabIndex = 17;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 76);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(32, 13);
|
||||
this.label2.TabIndex = 16;
|
||||
this.label2.Text = "Desc";
|
||||
//
|
||||
// desc
|
||||
//
|
||||
this.desc.Location = new System.Drawing.Point(66, 73);
|
||||
this.desc.Name = "desc";
|
||||
this.desc.Size = new System.Drawing.Size(286, 20);
|
||||
this.desc.TabIndex = 17;
|
||||
//
|
||||
// selectable
|
||||
//
|
||||
this.selectable.AutoSize = true;
|
||||
this.selectable.Location = new System.Drawing.Point(118, 138);
|
||||
this.selectable.Name = "selectable";
|
||||
this.selectable.Size = new System.Drawing.Size(130, 17);
|
||||
this.selectable.TabIndex = 18;
|
||||
this.selectable.Text = "Show in Map Chooser";
|
||||
this.selectable.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 102);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(38, 13);
|
||||
this.label3.TabIndex = 16;
|
||||
this.label3.Text = "Author";
|
||||
//
|
||||
// author
|
||||
//
|
||||
this.author.Location = new System.Drawing.Point(66, 99);
|
||||
this.author.Name = "author";
|
||||
this.author.Size = new System.Drawing.Size(286, 20);
|
||||
this.author.TabIndex = 17;
|
||||
//
|
||||
// checkBox1
|
||||
//
|
||||
this.useAsShellmap.AutoSize = true;
|
||||
this.useAsShellmap.Location = new System.Drawing.Point(118, 161);
|
||||
this.useAsShellmap.Name = "checkBox1";
|
||||
this.useAsShellmap.Size = new System.Drawing.Size(105, 17);
|
||||
this.useAsShellmap.TabIndex = 18;
|
||||
this.useAsShellmap.Text = "Use as Shellmap";
|
||||
this.useAsShellmap.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// PropertiesDialog
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.button1;
|
||||
this.ClientSize = new System.Drawing.Size(370, 228);
|
||||
this.Controls.Add(this.useAsShellmap);
|
||||
this.Controls.Add(this.selectable);
|
||||
this.Controls.Add(this.author);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.desc);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.title);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Name = "PropertiesDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Map Properties";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -177,6 +177,6 @@ namespace OpenRA.Editor
|
||||
public System.Windows.Forms.CheckBox selectable;
|
||||
private System.Windows.Forms.Label label3;
|
||||
public System.Windows.Forms.TextBox author;
|
||||
public System.Windows.Forms.CheckBox useAsShellmap;
|
||||
public System.Windows.Forms.CheckBox useAsShellmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -18,45 +18,6 @@ namespace OpenRA.Editor
|
||||
{
|
||||
static class RenderUtils
|
||||
{
|
||||
public static Bitmap RenderTemplate(TileSet ts, ushort n, Palette p)
|
||||
{
|
||||
var template = ts.Templates[n];
|
||||
var tile = ts.Tiles[n];
|
||||
|
||||
var bitmap = new Bitmap(ts.TileSize * template.Size.X, ts.TileSize * template.Size.Y,
|
||||
PixelFormat.Format8bppIndexed);
|
||||
|
||||
bitmap.Palette = p.AsSystemPalette();
|
||||
|
||||
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
|
||||
unsafe
|
||||
{
|
||||
byte* q = (byte*)data.Scan0.ToPointer();
|
||||
var stride = data.Stride;
|
||||
|
||||
for (var u = 0; u < template.Size.X; u++)
|
||||
for (var v = 0; v < template.Size.Y; v++)
|
||||
if (tile.TileBitmapBytes[u + v * template.Size.X] != null)
|
||||
{
|
||||
var rawImage = tile.TileBitmapBytes[u + v * template.Size.X];
|
||||
for (var i = 0; i < ts.TileSize; i++)
|
||||
for (var j = 0; j < ts.TileSize; j++)
|
||||
q[(v * ts.TileSize + j) * stride + u * ts.TileSize + i] = rawImage[i + ts.TileSize * j];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < ts.TileSize; i++)
|
||||
for (var j = 0; j < ts.TileSize; j++)
|
||||
q[(v * ts.TileSize + j) * stride + u * ts.TileSize + i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bitmap.UnlockBits(data);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static Bitmap RenderShp(ShpReader shp, Palette p)
|
||||
{
|
||||
var frame = shp[0];
|
||||
@@ -84,9 +45,9 @@ namespace OpenRA.Editor
|
||||
|
||||
public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p)
|
||||
{
|
||||
var image = RenderSimple.GetImage(info);
|
||||
|
||||
using (var s = FileSystem.OpenWithExts(image, tileset.Extensions))
|
||||
var image = RenderSimple.GetImage(info);
|
||||
|
||||
using (var s = FileSystem.OpenWithExts(image, tileset.Extensions))
|
||||
{
|
||||
var shp = new ShpReader(s);
|
||||
var bitmap = RenderShp(shp, p);
|
||||
|
||||
114
OpenRA.Editor/ResizeDialog.Designer.cs
generated
114
OpenRA.Editor/ResizeDialog.Designer.cs
generated
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -56,101 +56,101 @@ namespace OpenRA.Editor
|
||||
((System.ComponentModel.ISupportInitialize)(this.cordonBottom)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.height)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
//
|
||||
// width
|
||||
//
|
||||
//
|
||||
this.width.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.width.Location = new System.Drawing.Point(161, 18);
|
||||
this.width.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.width.Name = "width";
|
||||
this.width.Size = new System.Drawing.Size(105, 20);
|
||||
this.width.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// label1
|
||||
//
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(23, 20);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Size";
|
||||
//
|
||||
//
|
||||
// label2
|
||||
//
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(23, 46);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(86, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Cordon Left/Top";
|
||||
//
|
||||
//
|
||||
// cordonLeft
|
||||
//
|
||||
//
|
||||
this.cordonLeft.Location = new System.Drawing.Point(161, 44);
|
||||
this.cordonLeft.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonLeft.Name = "cordonLeft";
|
||||
this.cordonLeft.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonLeft.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// cordonTop
|
||||
//
|
||||
//
|
||||
this.cordonTop.Location = new System.Drawing.Point(272, 44);
|
||||
this.cordonTop.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonTop.Name = "cordonTop";
|
||||
this.cordonTop.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonTop.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// cordonRight
|
||||
//
|
||||
//
|
||||
this.cordonRight.Location = new System.Drawing.Point(161, 70);
|
||||
this.cordonRight.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonRight.Name = "cordonRight";
|
||||
this.cordonRight.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonRight.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// cordonBottom
|
||||
//
|
||||
//
|
||||
this.cordonBottom.Location = new System.Drawing.Point(272, 70);
|
||||
this.cordonBottom.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.cordonBottom.Name = "cordonBottom";
|
||||
this.cordonBottom.Size = new System.Drawing.Size(105, 20);
|
||||
this.cordonBottom.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// label3
|
||||
//
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(23, 72);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(107, 13);
|
||||
this.label3.TabIndex = 1;
|
||||
this.label3.Text = "Cordon Right/Bottom";
|
||||
//
|
||||
//
|
||||
// button1
|
||||
//
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(302, 111);
|
||||
this.button1.Name = "button1";
|
||||
@@ -158,9 +158,9 @@ namespace OpenRA.Editor
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// button2
|
||||
//
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Location = new System.Drawing.Point(221, 111);
|
||||
this.button2.Name = "button2";
|
||||
@@ -168,26 +168,26 @@ namespace OpenRA.Editor
|
||||
this.button2.TabIndex = 2;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
//
|
||||
// height
|
||||
//
|
||||
//
|
||||
this.height.Increment = new decimal(new int[] {
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.height.Location = new System.Drawing.Point(272, 18);
|
||||
this.height.Maximum = new decimal(new int[] {
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
2048,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.height.Name = "height";
|
||||
this.height.Size = new System.Drawing.Size(105, 20);
|
||||
this.height.TabIndex = 0;
|
||||
//
|
||||
//
|
||||
// ResizeDialog
|
||||
//
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Editor
|
||||
index = (byte)random.Next(Resource.Info.SpriteNames.Length)
|
||||
};
|
||||
|
||||
var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
|
||||
var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
|
||||
(surface.GetBrushLocation().Y) / Surface.ChunkSize);
|
||||
|
||||
if (surface.Chunks.ContainsKey(ch))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -33,12 +33,16 @@ namespace OpenRA.Editor
|
||||
public float Zoom = 1.0f;
|
||||
|
||||
ITool Tool;
|
||||
|
||||
|
||||
public bool IsPanning;
|
||||
public bool ShowActorNames;
|
||||
public bool ShowGrid;
|
||||
|
||||
public string NewActorOwner;
|
||||
|
||||
public event Action AfterChange = () => { };
|
||||
public event Action<string> MousePositionChanged = _ => { };
|
||||
public event Action<KeyValuePair<string, ActorReference>> ActorDoubleClicked = _ => { };
|
||||
|
||||
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>();
|
||||
Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
|
||||
@@ -88,6 +92,15 @@ namespace OpenRA.Editor
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnDoubleClick(EventArgs e)
|
||||
{
|
||||
base.OnDoubleClick(e);
|
||||
|
||||
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
|
||||
if (x.Key != null)
|
||||
ActorDoubleClicked(x);
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseWheel(e);
|
||||
@@ -153,7 +166,7 @@ namespace OpenRA.Editor
|
||||
return;
|
||||
|
||||
Tool = null;
|
||||
|
||||
|
||||
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == BrushLocation);
|
||||
if (key.Key != null) Map.Actors.Value.Remove(key.Key);
|
||||
|
||||
@@ -198,7 +211,6 @@ namespace OpenRA.Editor
|
||||
{
|
||||
|
||||
var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize);
|
||||
bitmap.SetPixel(0, 0, Color.Green);
|
||||
|
||||
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
@@ -212,7 +224,7 @@ namespace OpenRA.Editor
|
||||
for (var j = 0; j < ChunkSize; j++)
|
||||
{
|
||||
var tr = Map.MapTiles.Value[u * ChunkSize + i, v * ChunkSize + j];
|
||||
var tile = TileSet.Tiles[tr.type];
|
||||
var tile = TileSet.Templates[tr.type].Data;
|
||||
var index = (tr.index < tile.TileBitmapBytes.Count) ? tr.index : (byte)0;
|
||||
var rawImage = tile.TileBitmapBytes[index];
|
||||
for (var x = 0; x < TileSet.TileSize; x++)
|
||||
@@ -242,6 +254,16 @@ namespace OpenRA.Editor
|
||||
}
|
||||
|
||||
bitmap.UnlockBits(data);
|
||||
|
||||
if (ShowGrid)
|
||||
using( var g = SGraphics.FromImage(bitmap) )
|
||||
{
|
||||
var rect = new Rectangle(0,0,bitmap.Width, bitmap.Height);
|
||||
ControlPaint.DrawGrid( g, rect, new Size(2, Game.CellSize), Color.DarkRed );
|
||||
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, 2), Color.DarkRed );
|
||||
ControlPaint.DrawGrid( g, rect, new Size(Game.CellSize, Game.CellSize), Color.Red );
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@@ -282,36 +304,41 @@ namespace OpenRA.Editor
|
||||
if (cp != null) bmp.Palette = restorePalette;
|
||||
}
|
||||
|
||||
void DrawActorBorder(System.Drawing.Graphics g, int2 p, ActorTemplate t)
|
||||
void DrawActorBorder(SGraphics g, int2 p, ActorTemplate t)
|
||||
{
|
||||
var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
|
||||
var drawPos = GetDrawPosition(p, t.Bitmap, centered);
|
||||
|
||||
|
||||
g.DrawRectangle(CordonPen,
|
||||
drawPos.X, drawPos.Y,
|
||||
t.Bitmap.Width * Zoom, t.Bitmap.Height * Zoom);
|
||||
}
|
||||
|
||||
ColorPalette GetPaletteForPlayer(string name)
|
||||
ColorPalette GetPaletteForPlayerInner(string name)
|
||||
{
|
||||
var pr = Map.Players[name];
|
||||
var pcpi = Rules.Info["player"].Traits.Get<PlayerColorPaletteInfo>();
|
||||
var remap = new PlayerColorRemap(pr.ColorRamp, pcpi.PaletteFormat);
|
||||
var remap = new PlayerColorRemap(pcpi.PaletteFormat, pr.ColorRamp);
|
||||
return new Palette(Palette, remap).AsSystemPalette();
|
||||
}
|
||||
|
||||
Cache<string, ColorPalette> PlayerPalettes;
|
||||
|
||||
ColorPalette GetPaletteForActor(ActorReference ar)
|
||||
public ColorPalette GetPaletteForPlayer(string player)
|
||||
{
|
||||
if (PlayerPalettes == null)
|
||||
PlayerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayer);
|
||||
PlayerPalettes = new Cache<string, ColorPalette>(GetPaletteForPlayerInner);
|
||||
|
||||
return PlayerPalettes[player];
|
||||
}
|
||||
|
||||
ColorPalette GetPaletteForActor(ActorReference ar)
|
||||
{
|
||||
var ownerInit = ar.InitDict.GetOrDefault<OwnerInit>();
|
||||
if (ownerInit == null)
|
||||
return null;
|
||||
|
||||
return PlayerPalettes[ownerInit.PlayerName];
|
||||
return GetPaletteForPlayer(ownerInit.PlayerName);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
@@ -360,7 +387,7 @@ namespace OpenRA.Editor
|
||||
|
||||
if (Tool != null)
|
||||
Tool.Preview(this, e.Graphics);
|
||||
|
||||
|
||||
if (Tool == null)
|
||||
{
|
||||
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -12,36 +12,36 @@ using System.Drawing;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
public struct ColorRamp
|
||||
{
|
||||
public byte H,S,L,R;
|
||||
public struct ColorRamp
|
||||
{
|
||||
public byte H,S,L,R;
|
||||
|
||||
public ColorRamp(byte h, byte s, byte l, byte r)
|
||||
{
|
||||
H = h; S = s; L = l; R = r;
|
||||
}
|
||||
public ColorRamp(byte h, byte s, byte l, byte r)
|
||||
{
|
||||
H = h; S = s; L = l; R = r;
|
||||
}
|
||||
|
||||
/* returns a color along the Lum ramp */
|
||||
public Color GetColor( float t )
|
||||
{
|
||||
return ColorFromHSL( H / 255f, S / 255f, float2.Lerp( L / 255f, L*R / (255f * 255f), t ) );
|
||||
}
|
||||
public static readonly ColorRamp Empty = new ColorRamp(0,0,0,0);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{0},{1},{2},{3}".F(H, S, L, R);
|
||||
}
|
||||
/* returns a color along the Lum ramp */
|
||||
public Color GetColor( float t )
|
||||
{
|
||||
return ColorFromHSL( H / 255f, S / 255f, float2.Lerp( L / 255f, L*R / (255f * 255f), t ) );
|
||||
}
|
||||
|
||||
// hk is hue in the range [0,1] instead of [0,360]
|
||||
public override string ToString()
|
||||
{
|
||||
return "{0},{1},{2},{3}".F(H, S, L, R);
|
||||
}
|
||||
|
||||
// hk is hue in the range [0,1] instead of [0,360]
|
||||
public static Color ColorFromHSL(float hk, float s, float l)
|
||||
{
|
||||
// Convert from HSL to RGB
|
||||
var q = (l < 0.5f) ? l * (1 + s) : l + s - (l * s);
|
||||
var p = 2 * l - q;
|
||||
|
||||
float[] trgb = { hk + 1 / 3.0f,
|
||||
hk,
|
||||
hk - 1/3.0f };
|
||||
float[] trgb = { hk + 1 / 3.0f, hk, hk - 1/3.0f };
|
||||
float[] rgb = { 0, 0, 0 };
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
@@ -60,5 +60,23 @@ namespace OpenRA.FileFormats
|
||||
|
||||
return Color.FromArgb((int)(rgb[0] * 255), (int)(rgb[1] * 255), (int)(rgb[2] * 255));
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(ColorRamp me, ColorRamp other)
|
||||
{
|
||||
return (me.H == other.H && me.S == other.S && me.L == other.L && me.R == other.R );
|
||||
}
|
||||
|
||||
public static bool operator !=(ColorRamp me, ColorRamp other) { return !(me == other); }
|
||||
|
||||
public override int GetHashCode() { return H.GetHashCode() ^ S.GetHashCode() ^ L.GetHashCode() ^ R.GetHashCode(); }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
ColorRamp o = (ColorRamp)obj;
|
||||
return o == this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -61,11 +61,11 @@ namespace OpenRA.FileFormats
|
||||
while ((temp = s.Pop()) != "(") yield return temp;
|
||||
}
|
||||
else if (char.IsNumber(t[0])) yield return t;
|
||||
else if (char.IsLetter(t[0]))
|
||||
else if (char.IsLetter(t[0]))
|
||||
{
|
||||
if (!syms.ContainsKey(t))
|
||||
throw new InvalidOperationException("Substitution `{0}` undefined".F(t));
|
||||
|
||||
|
||||
yield return syms[t].ToString();
|
||||
}
|
||||
else
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.FileFormats
|
||||
s.Push(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (s.Count > 0) yield return s.Pop();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -24,6 +24,12 @@ namespace OpenRA
|
||||
return string.Format(fmt, args);
|
||||
}
|
||||
|
||||
public static T WithDefault<T>(T def, Func<T> f)
|
||||
{
|
||||
try { return f(); }
|
||||
catch { return def; }
|
||||
}
|
||||
|
||||
public static void Do<T>(this IEnumerable<T> e, Action<T> fn)
|
||||
{
|
||||
foreach (var ee in e)
|
||||
@@ -107,49 +113,49 @@ namespace OpenRA
|
||||
return r.Contains(p.ToPointF());
|
||||
}
|
||||
|
||||
public static bool HasModifier(this Modifiers k, Modifiers mod)
|
||||
{
|
||||
return (k & mod) == mod;
|
||||
}
|
||||
|
||||
public static bool HasModifier(this Modifiers k, Modifiers mod)
|
||||
{
|
||||
return (k & mod) == mod;
|
||||
}
|
||||
|
||||
public static bool IsValidInput(this KeyInput key)
|
||||
{
|
||||
return char.IsLetter(key.UnicodeChar) || char.IsDigit(key.UnicodeChar) ||
|
||||
char.IsSymbol(key.UnicodeChar) || char.IsSeparator(key.UnicodeChar) ||
|
||||
return char.IsLetter(key.UnicodeChar) || char.IsDigit(key.UnicodeChar) ||
|
||||
char.IsSymbol(key.UnicodeChar) || char.IsSeparator(key.UnicodeChar) ||
|
||||
char.IsPunctuation(key.UnicodeChar);
|
||||
}
|
||||
|
||||
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k)
|
||||
where V : new()
|
||||
{
|
||||
return d.GetOrAdd(k, _ => new V());
|
||||
}
|
||||
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k)
|
||||
where V : new()
|
||||
{
|
||||
return d.GetOrAdd(k, _ => new V());
|
||||
}
|
||||
|
||||
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k, Func<K, V> createFn)
|
||||
{
|
||||
V ret;
|
||||
if (!d.TryGetValue(k, out ret))
|
||||
d.Add(k, ret = createFn(k));
|
||||
return ret;
|
||||
}
|
||||
public static V GetOrAdd<K, V>(this Dictionary<K, V> d, K k, Func<K, V> createFn)
|
||||
{
|
||||
V ret;
|
||||
if (!d.TryGetValue(k, out ret))
|
||||
d.Add(k, ret = createFn(k));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static T Random<T>(this IEnumerable<T> ts, Thirdparty.Random r)
|
||||
{
|
||||
var xs = ts.ToArray();
|
||||
return xs[r.Next(xs.Length)];
|
||||
}
|
||||
public static T Random<T>(this IEnumerable<T> ts, Thirdparty.Random r)
|
||||
{
|
||||
var xs = ts.ToArray();
|
||||
return xs[r.Next(xs.Length)];
|
||||
}
|
||||
|
||||
public static float Product(this IEnumerable<float> xs)
|
||||
{
|
||||
return xs.Aggregate(1f, (a, x) => a * x);
|
||||
}
|
||||
public static float Product(this IEnumerable<float> xs)
|
||||
{
|
||||
return xs.Aggregate(1f, (a, x) => a * x);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SymmetricDifference<T>(this IEnumerable<T> xs, IEnumerable<T> ys)
|
||||
{
|
||||
// this is probably a shockingly-slow way to do this, but it's concise.
|
||||
return xs.Except(ys).Concat(ys.Except(xs));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SymmetricDifference<T>(this IEnumerable<T> xs, IEnumerable<T> ys)
|
||||
{
|
||||
// this is probably a shockingly-slow way to do this, but it's concise.
|
||||
return xs.Except(ys).Concat(ys.Except(xs));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Iterate<T>( this T t, Func<T,T> f )
|
||||
{
|
||||
for(;;) { yield return t; t = f(t); }
|
||||
@@ -165,5 +171,10 @@ namespace OpenRA
|
||||
++v;
|
||||
return v;
|
||||
}
|
||||
|
||||
public static string JoinWith<T>(this IEnumerable<T> ts, string j)
|
||||
{
|
||||
return string.Join(j, ts.Select(t => t.ToString()).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.FileFormats
|
||||
field.SetValue( self, GetValue( field.Name, field.FieldType, value ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var prop = self.GetType().GetProperty( key.Trim() );
|
||||
|
||||
if (prop != null)
|
||||
@@ -143,63 +143,63 @@ namespace OpenRA.FileFormats
|
||||
return InvalidValueAction(x,fieldType, field);
|
||||
}
|
||||
|
||||
else if (fieldType == typeof(ColorRamp))
|
||||
{
|
||||
var parts = x.Split(',');
|
||||
if (parts.Length == 4)
|
||||
return new ColorRamp(
|
||||
(byte)int.Parse(parts[0]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[1]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[2]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[3]).Clamp(0, 255));
|
||||
else if (fieldType == typeof(ColorRamp))
|
||||
{
|
||||
var parts = x.Split(',');
|
||||
if (parts.Length == 4)
|
||||
return new ColorRamp(
|
||||
(byte)int.Parse(parts[0]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[1]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[2]).Clamp(0, 255),
|
||||
(byte)int.Parse(parts[3]).Clamp(0, 255));
|
||||
|
||||
return InvalidValueAction(x, fieldType, field);
|
||||
}
|
||||
return InvalidValueAction(x, fieldType, field);
|
||||
}
|
||||
|
||||
else if (fieldType.IsEnum)
|
||||
{
|
||||
if (!Enum.GetNames(fieldType).Select(a => a.ToLower()).Contains(x.ToLower()))
|
||||
return InvalidValueAction(x, fieldType, field);
|
||||
return Enum.Parse(fieldType, x, true);
|
||||
}
|
||||
else if (fieldType.IsEnum)
|
||||
{
|
||||
if (!Enum.GetNames(fieldType).Select(a => a.ToLower()).Contains(x.ToLower()))
|
||||
return InvalidValueAction(x, fieldType, field);
|
||||
return Enum.Parse(fieldType, x, true);
|
||||
}
|
||||
|
||||
else if (fieldType == typeof(bool))
|
||||
return ParseYesNo(x, fieldType, field);
|
||||
else if (fieldType == typeof(bool))
|
||||
return ParseYesNo(x, fieldType, field);
|
||||
|
||||
else if (fieldType.IsArray)
|
||||
{
|
||||
if (x == null)
|
||||
return Array.CreateInstance(fieldType.GetElementType(), 0);
|
||||
else if (fieldType.IsArray)
|
||||
{
|
||||
if (x == null)
|
||||
return Array.CreateInstance(fieldType.GetElementType(), 0);
|
||||
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i);
|
||||
return ret;
|
||||
}
|
||||
else if (fieldType == typeof(int2))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new int2(int.Parse(parts[0]), int.Parse(parts[1]));
|
||||
}
|
||||
else if (fieldType == typeof(float2))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
float xx = 0;
|
||||
float yy = 0;
|
||||
float res;
|
||||
if (float.TryParse(parts[0].Replace("%", ""), out res))
|
||||
xx = res * (parts[0].Contains('%') ? 0.01f : 1f);
|
||||
if (float.TryParse(parts[1].Replace("%", ""), out res))
|
||||
yy = res * (parts[1].Contains('%') ? 0.01f : 1f);
|
||||
return new float2(xx, yy);
|
||||
}
|
||||
var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i);
|
||||
return ret;
|
||||
}
|
||||
else if (fieldType == typeof(int2))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new int2(int.Parse(parts[0]), int.Parse(parts[1]));
|
||||
}
|
||||
else if (fieldType == typeof(float2))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
float xx = 0;
|
||||
float yy = 0;
|
||||
float res;
|
||||
if (float.TryParse(parts[0].Replace("%", ""), out res))
|
||||
xx = res * (parts[0].Contains('%') ? 0.01f : 1f);
|
||||
if (float.TryParse(parts[1].Replace("%", ""), out res))
|
||||
yy = res * (parts[1].Contains('%') ? 0.01f : 1f);
|
||||
return new float2(xx, yy);
|
||||
}
|
||||
else if (fieldType == typeof(Rectangle))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
|
||||
}
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
|
||||
}
|
||||
else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Bits<>))
|
||||
{
|
||||
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
@@ -207,7 +207,7 @@ namespace OpenRA.FileFormats
|
||||
var argValues = new object[] { parts };
|
||||
return fieldType.GetConstructor(argTypes).Invoke(argValues);
|
||||
}
|
||||
|
||||
|
||||
UnknownFieldAction("[Type] {0}".F(x),fieldType);
|
||||
return null;
|
||||
}
|
||||
@@ -304,15 +304,14 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
return new MiniYamlNode(field, FieldSaver.FormatValue( o, o.GetType().GetField(field) ));
|
||||
}
|
||||
|
||||
public static string FormatValue(object o, FieldInfo f)
|
||||
|
||||
public static string FormatValue(object v, Type t)
|
||||
{
|
||||
var v = f.GetValue(o);
|
||||
if (v == null)
|
||||
return "";
|
||||
|
||||
// Color.ToString() does the wrong thing; force it to format as an array
|
||||
if (f.FieldType == typeof(Color))
|
||||
if (t == typeof(Color))
|
||||
{
|
||||
var c = (Color)v;
|
||||
return "{0},{1},{2},{3}".F(((int)c.A).Clamp(0, 255),
|
||||
@@ -321,20 +320,25 @@ namespace OpenRA.FileFormats
|
||||
((int)c.B).Clamp(0, 255));
|
||||
}
|
||||
|
||||
if (f.FieldType == typeof(Rectangle))
|
||||
if (t == typeof(Rectangle))
|
||||
{
|
||||
var r = (Rectangle)v;
|
||||
return "{0},{1},{2},{3}".F(r.X, r.Y, r.Width, r.Height);
|
||||
}
|
||||
|
||||
if (f.FieldType.IsArray)
|
||||
if (t.IsArray)
|
||||
{
|
||||
var elems = ((Array)v).OfType<object>();
|
||||
return string.Join(",", elems.Select(a => a.ToString()).ToArray());
|
||||
return elems.JoinWith(",");
|
||||
}
|
||||
|
||||
return v.ToString();
|
||||
}
|
||||
|
||||
public static string FormatValue(object o, FieldInfo f)
|
||||
{
|
||||
return FormatValue(f.GetValue(o), f.FieldType);
|
||||
}
|
||||
}
|
||||
|
||||
public class FieldFromYamlKeyAttribute : Attribute { }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -109,13 +109,13 @@ namespace OpenRA.FileFormats
|
||||
/*var dataSize = */ br.ReadInt32();
|
||||
var outputSize = br.ReadInt32();
|
||||
var flags = (SoundFlags) br.ReadByte();
|
||||
|
||||
|
||||
var samples = outputSize;
|
||||
if (0 != (flags & SoundFlags.Stereo)) samples /= 2;
|
||||
if (0 != (flags & SoundFlags._16Bit)) samples /= 2;
|
||||
return samples / sampleRate;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] LoadSound(Stream s)
|
||||
{
|
||||
var br = new BinaryReader(s);
|
||||
@@ -140,9 +140,9 @@ namespace OpenRA.FileFormats
|
||||
var t = DecodeSample(b, ref index, ref currentSample);
|
||||
output[offset++] = (byte)t;
|
||||
output[offset++] = (byte)(t >> 8);
|
||||
|
||||
|
||||
if (offset < outputSize)
|
||||
{
|
||||
{
|
||||
/* possible that only half of the final byte is used! */
|
||||
t = DecodeSample((byte)(b >> 4), ref index, ref currentSample);
|
||||
output[offset++] = (byte)t;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*
|
||||
* This file is based on the blast routines (version 1.1 by Mark Adler)
|
||||
* This file is based on the blast routines (version 1.1 by Mark Adler)
|
||||
* included in zlib/contrib
|
||||
*/
|
||||
#endregion
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public static readonly int MAXBITS = 13; // maximum code length
|
||||
public static readonly int MAXWIN = 4096; // maximum window size
|
||||
|
||||
|
||||
static byte[] litlen = new byte[] {
|
||||
11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
|
||||
10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
|
||||
@@ -51,28 +51,28 @@ namespace OpenRA.FileFormats
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
|
||||
3, 4, 5, 6, 7, 8
|
||||
};
|
||||
|
||||
|
||||
static Huffman litcode = new Huffman(litlen, litlen.Length, 256);
|
||||
static Huffman lencode = new Huffman(lenlen, lenlen.Length, 16);
|
||||
static Huffman distcode = new Huffman(distlen, distlen.Length, 64);
|
||||
|
||||
|
||||
// Decode PKWare Compression Library stream.
|
||||
public static byte[] Decompress(byte[] src)
|
||||
{
|
||||
BitReader br = new BitReader(src);
|
||||
|
||||
|
||||
// Are literals coded?
|
||||
int coded = br.ReadBits(8);
|
||||
|
||||
|
||||
if (coded < 0 || coded > 1)
|
||||
throw new NotImplementedException("Invalid datastream");
|
||||
bool EncodedLiterals = (coded == 1);
|
||||
|
||||
|
||||
// log2(dictionary size) - 6
|
||||
int dict = br.ReadBits(8);
|
||||
if (dict < 4 || dict > 6)
|
||||
throw new InvalidDataException("Invalid dictionary size");
|
||||
|
||||
throw new InvalidDataException("Invalid dictionary size");
|
||||
|
||||
// output state
|
||||
ushort next = 0; // index of next write location in out[]
|
||||
bool first = true; // true to check distances (for first 4K)
|
||||
@@ -94,33 +94,33 @@ namespace OpenRA.FileFormats
|
||||
ms.WriteByte(outBuffer[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Distance
|
||||
symbol = len == 2 ? 2 : dict;
|
||||
int dist = Decode(distcode, br) << symbol;
|
||||
dist += br.ReadBits(symbol);
|
||||
dist++;
|
||||
|
||||
|
||||
if (first && dist > next)
|
||||
throw new InvalidDataException("Attempt to jump before data");
|
||||
|
||||
|
||||
// copy length bytes from distance bytes back
|
||||
do
|
||||
{
|
||||
int dest = next;
|
||||
int source = dest - dist;
|
||||
|
||||
|
||||
int copy = MAXWIN;
|
||||
if (next < dist)
|
||||
{
|
||||
source += copy;
|
||||
copy = dist;
|
||||
}
|
||||
|
||||
|
||||
copy -= next;
|
||||
if (copy > len)
|
||||
copy = len;
|
||||
|
||||
|
||||
len -= copy;
|
||||
next += (ushort)copy;
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
|
||||
// the same as Array.Copy()
|
||||
while( copy-- > 0 )
|
||||
outBuffer[dest++] = outBuffer[source++];
|
||||
|
||||
|
||||
// Flush window to outstream
|
||||
if (next == MAXWIN)
|
||||
{
|
||||
@@ -153,11 +153,11 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
// Decode a code using huffman table h.
|
||||
|
||||
// Decode a code using huffman table h.
|
||||
static int Decode(Huffman h, BitReader br)
|
||||
{
|
||||
int code = 0; // len bits being decoded
|
||||
@@ -178,19 +178,19 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class BitReader
|
||||
{
|
||||
readonly byte[] src;
|
||||
int offset = 0;
|
||||
int offset = 0;
|
||||
int bitBuffer = 0;
|
||||
int bitCount = 0;
|
||||
|
||||
public BitReader(byte[] src)
|
||||
{
|
||||
this.src = src;
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
|
||||
public int ReadBits(int count)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -202,7 +202,7 @@ namespace OpenRA.FileFormats
|
||||
bitBuffer = src[offset++];
|
||||
bitCount = 8;
|
||||
}
|
||||
|
||||
|
||||
ret |= (bitBuffer & 1) << filled;
|
||||
bitBuffer >>= 1;
|
||||
bitCount--;
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
short[] length = new short[256]; // code lengths
|
||||
int s = 0; // current symbol
|
||||
|
||||
|
||||
// convert compact repeat counts into symbol bit length list
|
||||
foreach (byte code in rep)
|
||||
{
|
||||
@@ -242,16 +242,16 @@ namespace OpenRA.FileFormats
|
||||
} while (--num > 0);
|
||||
}
|
||||
n = s;
|
||||
|
||||
|
||||
// count number of codes of each length
|
||||
Count = new short[Blast.MAXBITS + 1];
|
||||
for (int i = 0; i < n; i++)
|
||||
Count[length[i]]++;
|
||||
|
||||
|
||||
// no codes!
|
||||
if (Count[0] == n)
|
||||
return;
|
||||
|
||||
|
||||
// check for an over-subscribed or incomplete set of lengths
|
||||
int left = 1; // one possible code of zero length
|
||||
for (int len = 1; len <= Blast.MAXBITS; len++)
|
||||
@@ -263,12 +263,12 @@ namespace OpenRA.FileFormats
|
||||
if (left < 0)
|
||||
throw new InvalidDataException ("over subscribed code set");
|
||||
}
|
||||
|
||||
|
||||
// generate offsets into symbol table for each length for sorting
|
||||
short[] offs = new short[Blast.MAXBITS + 1];
|
||||
for (int len = 1; len < Blast.MAXBITS; len++)
|
||||
offs[len + 1] = (short)(offs[len] + Count[len]);
|
||||
|
||||
|
||||
// put symbols in table sorted by length, by symbol order within each length
|
||||
Symbol = new short[SymbolCount];
|
||||
for (short i = 0; i < n; i++)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -13,516 +13,516 @@ using System.Linq;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
/* possibly the fugliest C# i've ever seen. */
|
||||
/* possibly the fugliest C# i've ever seen. */
|
||||
|
||||
class BlowfishKeyProvider
|
||||
{
|
||||
const string pubkeyStr = "AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V";
|
||||
class BlowfishKeyProvider
|
||||
{
|
||||
const string pubkeyStr = "AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V";
|
||||
|
||||
static sbyte[] char2num = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
|
||||
static sbyte[] char2num = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
|
||||
|
||||
class PublicKey
|
||||
{
|
||||
public uint[] key1 = new uint[64];
|
||||
public uint[] key2 = new uint[64];
|
||||
public uint len;
|
||||
}
|
||||
PublicKey pubkey = new PublicKey();
|
||||
class PublicKey
|
||||
{
|
||||
public uint[] key1 = new uint[64];
|
||||
public uint[] key2 = new uint[64];
|
||||
public uint len;
|
||||
}
|
||||
PublicKey pubkey = new PublicKey();
|
||||
|
||||
uint[] glob1 = new uint[64];
|
||||
uint glob1_bitlen, glob1_len_x2;
|
||||
uint[] glob2 = new uint[130];
|
||||
uint[] glob1_hi = new uint[4];
|
||||
uint[] glob1_hi_inv = new uint[4];
|
||||
uint glob1_hi_bitlen;
|
||||
uint glob1_hi_inv_lo, glob1_hi_inv_hi;
|
||||
uint[] glob1 = new uint[64];
|
||||
uint glob1_bitlen, glob1_len_x2;
|
||||
uint[] glob2 = new uint[130];
|
||||
uint[] glob1_hi = new uint[4];
|
||||
uint[] glob1_hi_inv = new uint[4];
|
||||
uint glob1_hi_bitlen;
|
||||
uint glob1_hi_inv_lo, glob1_hi_inv_hi;
|
||||
|
||||
void init_bignum(uint[] n, uint val, uint len)
|
||||
{
|
||||
for (int i = 0; i < len; i++) n[i] = 0;
|
||||
n[0] = val;
|
||||
}
|
||||
void init_bignum(uint[] n, uint val, uint len)
|
||||
{
|
||||
for (int i = 0; i < len; i++) n[i] = 0;
|
||||
n[0] = val;
|
||||
}
|
||||
|
||||
void move_key_to_big(uint[] n, byte[] key, uint klen, uint blen)
|
||||
{
|
||||
byte sign;
|
||||
void move_key_to_big(uint[] n, byte[] key, uint klen, uint blen)
|
||||
{
|
||||
byte sign;
|
||||
|
||||
if ((key[0] & 0x80) != 0) sign = 0xff;
|
||||
else sign = 0;
|
||||
if ((key[0] & 0x80) != 0) sign = 0xff;
|
||||
else sign = 0;
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn = &n[0])
|
||||
{
|
||||
byte* pn = (byte*)_pn;
|
||||
uint i = blen * 4;
|
||||
for (; i > klen; i--) pn[i - 1] = (byte)sign;
|
||||
for (; i > 0; i--) pn[i - 1] = key[klen - i];
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn = &n[0])
|
||||
{
|
||||
byte* pn = (byte*)_pn;
|
||||
uint i = blen * 4;
|
||||
for (; i > klen; i--) pn[i - 1] = (byte)sign;
|
||||
for (; i > 0; i--) pn[i - 1] = key[klen - i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void key_to_bignum(uint[] n, byte[] key, uint len)
|
||||
{
|
||||
uint keylen;
|
||||
int i;
|
||||
void key_to_bignum(uint[] n, byte[] key, uint len)
|
||||
{
|
||||
uint keylen;
|
||||
int i;
|
||||
|
||||
int j = 0;
|
||||
int j = 0;
|
||||
|
||||
if (key[j] != 2) return;
|
||||
j++;
|
||||
if (key[j] != 2) return;
|
||||
j++;
|
||||
|
||||
if ((key[j] & 0x80) != 0)
|
||||
{
|
||||
keylen = 0;
|
||||
for (i = 0; i < (key[j] & 0x7f); i++) keylen = (keylen << 8) | key[j + i + 1];
|
||||
j += (key[j] & 0x7f) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
keylen = key[j];
|
||||
j++;
|
||||
}
|
||||
if (keylen <= len * 4)
|
||||
move_key_to_big(n, key.Skip(j).ToArray(), keylen, len);
|
||||
}
|
||||
if ((key[j] & 0x80) != 0)
|
||||
{
|
||||
keylen = 0;
|
||||
for (i = 0; i < (key[j] & 0x7f); i++) keylen = (keylen << 8) | key[j + i + 1];
|
||||
j += (key[j] & 0x7f) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
keylen = key[j];
|
||||
j++;
|
||||
}
|
||||
if (keylen <= len * 4)
|
||||
move_key_to_big(n, key.Skip(j).ToArray(), keylen, len);
|
||||
}
|
||||
|
||||
uint len_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint i;
|
||||
i = len - 1;
|
||||
while ((i >= 0) && (n[i] == 0)) i--;
|
||||
return i + 1;
|
||||
}
|
||||
uint len_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint i;
|
||||
i = len - 1;
|
||||
while ((i >= 0) && (n[i] == 0)) i--;
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
uint bitlen_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint ddlen, bitlen, mask;
|
||||
ddlen = len_bignum(n, len);
|
||||
if (ddlen == 0) return 0;
|
||||
bitlen = ddlen * 32;
|
||||
mask = 0x80000000;
|
||||
while ((mask & n[ddlen - 1]) == 0)
|
||||
{
|
||||
mask >>= 1;
|
||||
bitlen--;
|
||||
}
|
||||
return bitlen;
|
||||
}
|
||||
uint bitlen_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint ddlen, bitlen, mask;
|
||||
ddlen = len_bignum(n, len);
|
||||
if (ddlen == 0) return 0;
|
||||
bitlen = ddlen * 32;
|
||||
mask = 0x80000000;
|
||||
while ((mask & n[ddlen - 1]) == 0)
|
||||
{
|
||||
mask >>= 1;
|
||||
bitlen--;
|
||||
}
|
||||
return bitlen;
|
||||
}
|
||||
|
||||
void init_pubkey()
|
||||
{
|
||||
int i = 0;
|
||||
uint i2, tmp;
|
||||
byte[] keytmp = new byte[256];
|
||||
void init_pubkey()
|
||||
{
|
||||
int i = 0;
|
||||
uint i2, tmp;
|
||||
byte[] keytmp = new byte[256];
|
||||
|
||||
init_bignum(pubkey.key2, 0x10001, 64);
|
||||
init_bignum(pubkey.key2, 0x10001, 64);
|
||||
|
||||
i2 = 0;
|
||||
while (i < pubkeyStr.Length)
|
||||
{
|
||||
tmp = (uint)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
keytmp[i2++] = (byte)((tmp >> 16) & 0xff);
|
||||
keytmp[i2++] = (byte)((tmp >> 8) & 0xff);
|
||||
keytmp[i2++] = (byte)(tmp & 0xff);
|
||||
}
|
||||
i2 = 0;
|
||||
while (i < pubkeyStr.Length)
|
||||
{
|
||||
tmp = (uint)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]];
|
||||
keytmp[i2++] = (byte)((tmp >> 16) & 0xff);
|
||||
keytmp[i2++] = (byte)((tmp >> 8) & 0xff);
|
||||
keytmp[i2++] = (byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
key_to_bignum(pubkey.key1, keytmp, 64);
|
||||
pubkey.len = bitlen_bignum(pubkey.key1, 64) - 1;
|
||||
}
|
||||
key_to_bignum(pubkey.key1, keytmp, 64);
|
||||
pubkey.len = bitlen_bignum(pubkey.key1, 64) - 1;
|
||||
}
|
||||
|
||||
uint len_predata()
|
||||
{
|
||||
uint a = (pubkey.len - 1) / 8;
|
||||
return (55 / a + 1) * (a + 1);
|
||||
}
|
||||
uint len_predata()
|
||||
{
|
||||
uint a = (pubkey.len - 1) / 8;
|
||||
return (55 / a + 1) * (a + 1);
|
||||
}
|
||||
|
||||
int cmp_bignum(uint[] n1, uint[] n2, uint len)
|
||||
{
|
||||
int cmp_bignum(uint[] n1, uint[] n2, uint len)
|
||||
{
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
--len;
|
||||
if (n1[len] < n2[len]) return -1;
|
||||
if (n1[len] > n2[len]) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
while (len > 0)
|
||||
{
|
||||
--len;
|
||||
if (n1[len] < n2[len]) return -1;
|
||||
if (n1[len] > n2[len]) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mov_bignum(uint[] dest, uint[] src, uint len)
|
||||
{
|
||||
Array.Copy(src, dest, len);
|
||||
}
|
||||
void mov_bignum(uint[] dest, uint[] src, uint len)
|
||||
{
|
||||
Array.Copy(src, dest, len);
|
||||
}
|
||||
|
||||
void shr_bignum(uint[] n, int bits, int len)
|
||||
{
|
||||
int i; int i2 = bits / 32;
|
||||
void shr_bignum(uint[] n, int bits, int len)
|
||||
{
|
||||
int i; int i2 = bits / 32;
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
for (i = 0; i < len - i2; i++) n[i] = n[i + i2];
|
||||
for (; i < len; i++) n[i] = 0;
|
||||
bits = bits % 32;
|
||||
}
|
||||
if (bits == 0) return;
|
||||
for (i = 0; i < len - 1; i++) n[i] = (n[i] >> bits) | (n[i + 1] << (32 -
|
||||
bits));
|
||||
n[i] = n[i] >> bits;
|
||||
}
|
||||
if (i2 > 0)
|
||||
{
|
||||
for (i = 0; i < len - i2; i++) n[i] = n[i + i2];
|
||||
for (; i < len; i++) n[i] = 0;
|
||||
bits = bits % 32;
|
||||
}
|
||||
if (bits == 0) return;
|
||||
for (i = 0; i < len - 1; i++) n[i] = (n[i] >> bits) | (n[i + 1] << (32 -
|
||||
bits));
|
||||
n[i] = n[i] >> bits;
|
||||
}
|
||||
|
||||
void shl_bignum(uint[] n, int bits, int len)
|
||||
{
|
||||
int i, i2;
|
||||
void shl_bignum(uint[] n, int bits, int len)
|
||||
{
|
||||
int i, i2;
|
||||
|
||||
i2 = bits / 32;
|
||||
if (i2 > 0)
|
||||
{
|
||||
for (i = len - 1; i > i2; i--) n[i] = n[i - i2];
|
||||
for (; i > 0; i--) n[i] = 0;
|
||||
bits = bits % 32;
|
||||
}
|
||||
if (bits == 0) return;
|
||||
for (i = len - 1; i > 0; i--) n[i] = (n[i] << bits) | (n[i - 1] >> (32 -
|
||||
bits));
|
||||
n[0] <<= bits;
|
||||
}
|
||||
i2 = bits / 32;
|
||||
if (i2 > 0)
|
||||
{
|
||||
for (i = len - 1; i > i2; i--) n[i] = n[i - i2];
|
||||
for (; i > 0; i--) n[i] = 0;
|
||||
bits = bits % 32;
|
||||
}
|
||||
if (bits == 0) return;
|
||||
for (i = len - 1; i > 0; i--) n[i] = (n[i] << bits) | (n[i - 1] >> (32 -
|
||||
bits));
|
||||
n[0] <<= bits;
|
||||
}
|
||||
|
||||
uint sub_bignum(uint[] dest, uint[] src1, uint[] src2, uint carry, int len)
|
||||
{
|
||||
uint i1, i2;
|
||||
uint sub_bignum(uint[] dest, uint[] src1, uint[] src2, uint carry, int len)
|
||||
{
|
||||
uint i1, i2;
|
||||
|
||||
len += len;
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _ps1 = &src1[0])
|
||||
fixed (uint* _ps2 = &src2[0])
|
||||
fixed (uint* _pd = &dest[0])
|
||||
{
|
||||
ushort* ps1 = (ushort*)_ps1;
|
||||
ushort* ps2 = (ushort*)_ps2;
|
||||
ushort* pd = (ushort*)_pd;
|
||||
len += len;
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _ps1 = &src1[0])
|
||||
fixed (uint* _ps2 = &src2[0])
|
||||
fixed (uint* _pd = &dest[0])
|
||||
{
|
||||
ushort* ps1 = (ushort*)_ps1;
|
||||
ushort* ps2 = (ushort*)_ps2;
|
||||
ushort* pd = (ushort*)_pd;
|
||||
|
||||
while (--len != -1)
|
||||
{
|
||||
i1 = *ps1++;
|
||||
i2 = *ps2++;
|
||||
*pd++ = (ushort)(i1 - i2 - carry);
|
||||
if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
while (--len != -1)
|
||||
{
|
||||
i1 = *ps1++;
|
||||
i2 = *ps2++;
|
||||
*pd++ = (ushort)(i1 - i2 - carry);
|
||||
if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
|
||||
unsafe uint sub_bignum(uint* dest, uint* src1, uint* src2, uint carry, int len)
|
||||
{
|
||||
uint i1, i2;
|
||||
unsafe uint sub_bignum(uint* dest, uint* src1, uint* src2, uint carry, int len)
|
||||
{
|
||||
uint i1, i2;
|
||||
|
||||
len += len;
|
||||
len += len;
|
||||
|
||||
ushort* ps1 = (ushort*)src1;
|
||||
ushort* ps2 = (ushort*)src2;
|
||||
ushort* pd = (ushort*)dest;
|
||||
ushort* ps1 = (ushort*)src1;
|
||||
ushort* ps2 = (ushort*)src2;
|
||||
ushort* pd = (ushort*)dest;
|
||||
|
||||
while (--len != -1)
|
||||
{
|
||||
i1 = *ps1++;
|
||||
i2 = *ps2++;
|
||||
*pd++ = (ushort)(i1 - i2 - carry);
|
||||
if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0;
|
||||
while (--len != -1)
|
||||
{
|
||||
i1 = *ps1++;
|
||||
i2 = *ps2++;
|
||||
*pd++ = (ushort)(i1 - i2 - carry);
|
||||
if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0;
|
||||
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
|
||||
void inv_bignum(uint[] n1, uint[] n2, uint len)
|
||||
{
|
||||
uint[] n_tmp = new uint[64];
|
||||
uint n2_bytelen, bit;
|
||||
int n2_bitlen;
|
||||
void inv_bignum(uint[] n1, uint[] n2, uint len)
|
||||
{
|
||||
uint[] n_tmp = new uint[64];
|
||||
uint n2_bytelen, bit;
|
||||
int n2_bitlen;
|
||||
|
||||
int j = 0;
|
||||
int j = 0;
|
||||
|
||||
init_bignum(n_tmp, 0, len);
|
||||
init_bignum(n1, 0, len);
|
||||
n2_bitlen = (int)bitlen_bignum(n2, len);
|
||||
bit = ((uint)1) << (n2_bitlen % 32);
|
||||
j = ((n2_bitlen + 32) / 32) - 1;
|
||||
n2_bytelen = (uint)((n2_bitlen - 1) / 32) * 4;
|
||||
n_tmp[n2_bytelen / 4] |= ((uint)1) << ((n2_bitlen - 1) & 0x1f);
|
||||
init_bignum(n_tmp, 0, len);
|
||||
init_bignum(n1, 0, len);
|
||||
n2_bitlen = (int)bitlen_bignum(n2, len);
|
||||
bit = ((uint)1) << (n2_bitlen % 32);
|
||||
j = ((n2_bitlen + 32) / 32) - 1;
|
||||
n2_bytelen = (uint)((n2_bitlen - 1) / 32) * 4;
|
||||
n_tmp[n2_bytelen / 4] |= ((uint)1) << ((n2_bitlen - 1) & 0x1f);
|
||||
|
||||
while (n2_bitlen > 0)
|
||||
{
|
||||
n2_bitlen--;
|
||||
shl_bignum(n_tmp, 1, (int)len);
|
||||
if (cmp_bignum(n_tmp, n2, len) != -1)
|
||||
{
|
||||
sub_bignum(n_tmp, n_tmp, n2, 0, (int)len);
|
||||
n1[j] |= bit;
|
||||
}
|
||||
bit >>= 1;
|
||||
if (bit == 0)
|
||||
{
|
||||
j--;
|
||||
bit = 0x80000000;
|
||||
}
|
||||
}
|
||||
init_bignum(n_tmp, 0, len);
|
||||
}
|
||||
while (n2_bitlen > 0)
|
||||
{
|
||||
n2_bitlen--;
|
||||
shl_bignum(n_tmp, 1, (int)len);
|
||||
if (cmp_bignum(n_tmp, n2, len) != -1)
|
||||
{
|
||||
sub_bignum(n_tmp, n_tmp, n2, 0, (int)len);
|
||||
n1[j] |= bit;
|
||||
}
|
||||
bit >>= 1;
|
||||
if (bit == 0)
|
||||
{
|
||||
j--;
|
||||
bit = 0x80000000;
|
||||
}
|
||||
}
|
||||
init_bignum(n_tmp, 0, len);
|
||||
}
|
||||
|
||||
void inc_bignum(uint[] n, uint len)
|
||||
{
|
||||
int i = 0;
|
||||
while ((++n[i] == 0) && (--len > 0)) i++;
|
||||
}
|
||||
void inc_bignum(uint[] n, uint len)
|
||||
{
|
||||
int i = 0;
|
||||
while ((++n[i] == 0) && (--len > 0)) i++;
|
||||
}
|
||||
|
||||
void init_two_dw(uint[] n, uint len)
|
||||
{
|
||||
mov_bignum(glob1, n, len);
|
||||
glob1_bitlen = bitlen_bignum(glob1, len);
|
||||
glob1_len_x2 = (glob1_bitlen + 15) / 16;
|
||||
mov_bignum(glob1_hi, glob1.Skip((int)len_bignum(glob1, len) - 2).ToArray(), 2);
|
||||
glob1_hi_bitlen = bitlen_bignum(glob1_hi, 2) - 32;
|
||||
shr_bignum(glob1_hi, (int)glob1_hi_bitlen, 2);
|
||||
inv_bignum(glob1_hi_inv, glob1_hi, 2);
|
||||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen = (glob1_hi_bitlen + 15) % 16 + 1;
|
||||
inc_bignum(glob1_hi_inv, 2);
|
||||
if (bitlen_bignum(glob1_hi_inv, 2) > 32)
|
||||
{
|
||||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen--;
|
||||
}
|
||||
glob1_hi_inv_lo = (ushort)glob1_hi_inv[0];
|
||||
glob1_hi_inv_hi = (ushort)(glob1_hi_inv[0] >> 16);
|
||||
}
|
||||
void init_two_dw(uint[] n, uint len)
|
||||
{
|
||||
mov_bignum(glob1, n, len);
|
||||
glob1_bitlen = bitlen_bignum(glob1, len);
|
||||
glob1_len_x2 = (glob1_bitlen + 15) / 16;
|
||||
mov_bignum(glob1_hi, glob1.Skip((int)len_bignum(glob1, len) - 2).ToArray(), 2);
|
||||
glob1_hi_bitlen = bitlen_bignum(glob1_hi, 2) - 32;
|
||||
shr_bignum(glob1_hi, (int)glob1_hi_bitlen, 2);
|
||||
inv_bignum(glob1_hi_inv, glob1_hi, 2);
|
||||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen = (glob1_hi_bitlen + 15) % 16 + 1;
|
||||
inc_bignum(glob1_hi_inv, 2);
|
||||
if (bitlen_bignum(glob1_hi_inv, 2) > 32)
|
||||
{
|
||||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen--;
|
||||
}
|
||||
glob1_hi_inv_lo = (ushort)glob1_hi_inv[0];
|
||||
glob1_hi_inv_hi = (ushort)(glob1_hi_inv[0] >> 16);
|
||||
}
|
||||
|
||||
unsafe void mul_bignum_word(ushort *pn1, uint[] n2, uint mul, uint len)
|
||||
{
|
||||
uint i, tmp;
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn2 = &n2[0])
|
||||
{
|
||||
ushort* pn2 = (ushort*)_pn2;
|
||||
unsafe void mul_bignum_word(ushort *pn1, uint[] n2, uint mul, uint len)
|
||||
{
|
||||
uint i, tmp;
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn2 = &n2[0])
|
||||
{
|
||||
ushort* pn2 = (ushort*)_pn2;
|
||||
|
||||
tmp = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tmp = mul * (*pn2) + (*pn1) + tmp;
|
||||
*pn1 = (ushort)tmp;
|
||||
pn1++;
|
||||
pn2++;
|
||||
tmp >>= 16;
|
||||
}
|
||||
*pn1 += (ushort)tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tmp = mul * (*pn2) + (*pn1) + tmp;
|
||||
*pn1 = (ushort)tmp;
|
||||
pn1++;
|
||||
pn2++;
|
||||
tmp >>= 16;
|
||||
}
|
||||
*pn1 += (ushort)tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mul_bignum(uint[] dest, uint[] src1, uint[] src2, uint len)
|
||||
{
|
||||
uint i;
|
||||
void mul_bignum(uint[] dest, uint[] src1, uint[] src2, uint len)
|
||||
{
|
||||
uint i;
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed( uint * _psrc2 = &src2[0] )
|
||||
fixed(uint* _pdest = &dest[0])
|
||||
{
|
||||
ushort* psrc2 = (ushort*)_psrc2;
|
||||
ushort* pdest = (ushort*)_pdest;
|
||||
unsafe
|
||||
{
|
||||
fixed( uint * _psrc2 = &src2[0] )
|
||||
fixed(uint* _pdest = &dest[0])
|
||||
{
|
||||
ushort* psrc2 = (ushort*)_psrc2;
|
||||
ushort* pdest = (ushort*)_pdest;
|
||||
|
||||
init_bignum(dest, 0, len * 2);
|
||||
for (i = 0; i < len * 2; i++)
|
||||
mul_bignum_word(pdest++, src1, *psrc2++, len * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
init_bignum(dest, 0, len * 2);
|
||||
for (i = 0; i < len * 2; i++)
|
||||
mul_bignum_word(pdest++, src1, *psrc2++, len * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void not_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < len; i++) n[i] = ~n[i];
|
||||
}
|
||||
void not_bignum(uint[] n, uint len)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < len; i++) n[i] = ~n[i];
|
||||
}
|
||||
|
||||
void neg_bignum(uint[] n, uint len)
|
||||
{
|
||||
not_bignum(n, len);
|
||||
inc_bignum(n, len);
|
||||
}
|
||||
void neg_bignum(uint[] n, uint len)
|
||||
{
|
||||
not_bignum(n, len);
|
||||
inc_bignum(n, len);
|
||||
}
|
||||
|
||||
unsafe uint get_mulword(uint* n)
|
||||
{
|
||||
ushort* wn = (ushort*)n;
|
||||
uint i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1)
|
||||
+ (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
||||
>> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
||||
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
||||
* (*wn ^ 0xffff) * 2) >> (int)glob1_hi_bitlen);
|
||||
if (i > 0xffff) i = 0xffff;
|
||||
return i & 0xffff;
|
||||
}
|
||||
unsafe uint get_mulword(uint* n)
|
||||
{
|
||||
ushort* wn = (ushort*)n;
|
||||
uint i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1)
|
||||
+ (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
||||
>> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
||||
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
||||
* (*wn ^ 0xffff) * 2) >> (int)glob1_hi_bitlen);
|
||||
if (i > 0xffff) i = 0xffff;
|
||||
return i & 0xffff;
|
||||
}
|
||||
|
||||
void dec_bignum(uint[] n, uint len)
|
||||
{
|
||||
int i = 0;
|
||||
while ((--n[i] == 0xffffffff) && (--len > 0))
|
||||
i++;
|
||||
}
|
||||
void dec_bignum(uint[] n, uint len)
|
||||
{
|
||||
int i = 0;
|
||||
while ((--n[i] == 0xffffffff) && (--len > 0))
|
||||
i++;
|
||||
}
|
||||
|
||||
void calc_a_bignum(uint[] n1, uint[] n2, uint[] n3, uint len)
|
||||
{
|
||||
uint g2_len_x2, len_diff;
|
||||
unsafe
|
||||
{
|
||||
fixed( uint* g1 = &glob1[0])
|
||||
fixed (uint* g2 = &glob2[0])
|
||||
{
|
||||
mul_bignum(glob2, n2, n3, len);
|
||||
glob2[len * 2] = 0;
|
||||
g2_len_x2 = len_bignum(glob2, len * 2 + 1) * 2;
|
||||
if (g2_len_x2 >= glob1_len_x2)
|
||||
{
|
||||
inc_bignum(glob2, len * 2 + 1);
|
||||
neg_bignum(glob2, len * 2 + 1);
|
||||
len_diff = g2_len_x2 + 1 - glob1_len_x2;
|
||||
ushort* esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2);
|
||||
ushort* edi = ((ushort*)g2) + (g2_len_x2 + 1);
|
||||
for (; len_diff != 0; len_diff--)
|
||||
{
|
||||
edi--;
|
||||
uint tmp = get_mulword((uint*)edi);
|
||||
esi--;
|
||||
if (tmp > 0)
|
||||
{
|
||||
mul_bignum_word(esi, glob1, tmp, 2 * len);
|
||||
if ((*edi & 0x8000) == 0)
|
||||
{
|
||||
if (0 != sub_bignum((uint*)esi, (uint*)esi, g1, 0, (int)len)) (*edi)--;
|
||||
}
|
||||
}
|
||||
}
|
||||
neg_bignum(glob2, len);
|
||||
dec_bignum(glob2, len);
|
||||
}
|
||||
mov_bignum(n1, glob2, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
void calc_a_bignum(uint[] n1, uint[] n2, uint[] n3, uint len)
|
||||
{
|
||||
uint g2_len_x2, len_diff;
|
||||
unsafe
|
||||
{
|
||||
fixed( uint* g1 = &glob1[0])
|
||||
fixed (uint* g2 = &glob2[0])
|
||||
{
|
||||
mul_bignum(glob2, n2, n3, len);
|
||||
glob2[len * 2] = 0;
|
||||
g2_len_x2 = len_bignum(glob2, len * 2 + 1) * 2;
|
||||
if (g2_len_x2 >= glob1_len_x2)
|
||||
{
|
||||
inc_bignum(glob2, len * 2 + 1);
|
||||
neg_bignum(glob2, len * 2 + 1);
|
||||
len_diff = g2_len_x2 + 1 - glob1_len_x2;
|
||||
ushort* esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2);
|
||||
ushort* edi = ((ushort*)g2) + (g2_len_x2 + 1);
|
||||
for (; len_diff != 0; len_diff--)
|
||||
{
|
||||
edi--;
|
||||
uint tmp = get_mulword((uint*)edi);
|
||||
esi--;
|
||||
if (tmp > 0)
|
||||
{
|
||||
mul_bignum_word(esi, glob1, tmp, 2 * len);
|
||||
if ((*edi & 0x8000) == 0)
|
||||
{
|
||||
if (0 != sub_bignum((uint*)esi, (uint*)esi, g1, 0, (int)len)) (*edi)--;
|
||||
}
|
||||
}
|
||||
}
|
||||
neg_bignum(glob2, len);
|
||||
dec_bignum(glob2, len);
|
||||
}
|
||||
mov_bignum(n1, glob2, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clear_tmp_vars(uint len)
|
||||
{
|
||||
init_bignum(glob1, 0, len);
|
||||
init_bignum(glob2, 0, len);
|
||||
init_bignum(glob1_hi_inv, 0, 4);
|
||||
init_bignum(glob1_hi, 0, 4);
|
||||
glob1_bitlen = 0;
|
||||
glob1_hi_bitlen = 0;
|
||||
glob1_len_x2 = 0;
|
||||
glob1_hi_inv_lo = 0;
|
||||
glob1_hi_inv_hi = 0;
|
||||
}
|
||||
void clear_tmp_vars(uint len)
|
||||
{
|
||||
init_bignum(glob1, 0, len);
|
||||
init_bignum(glob2, 0, len);
|
||||
init_bignum(glob1_hi_inv, 0, 4);
|
||||
init_bignum(glob1_hi, 0, 4);
|
||||
glob1_bitlen = 0;
|
||||
glob1_hi_bitlen = 0;
|
||||
glob1_len_x2 = 0;
|
||||
glob1_hi_inv_lo = 0;
|
||||
glob1_hi_inv_hi = 0;
|
||||
}
|
||||
|
||||
void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len)
|
||||
{
|
||||
uint[] n_tmp = new uint[64];
|
||||
uint n3_len, n4_len;
|
||||
int n3_bitlen;
|
||||
uint bit_mask;
|
||||
void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len)
|
||||
{
|
||||
uint[] n_tmp = new uint[64];
|
||||
uint n3_len, n4_len;
|
||||
int n3_bitlen;
|
||||
uint bit_mask;
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn3 = &n3[0])
|
||||
{
|
||||
uint* pn3 = _pn3;
|
||||
unsafe
|
||||
{
|
||||
fixed (uint* _pn3 = &n3[0])
|
||||
{
|
||||
uint* pn3 = _pn3;
|
||||
|
||||
init_bignum(n1, 1, len);
|
||||
n4_len = len_bignum(n4, len);
|
||||
init_two_dw(n4, n4_len);
|
||||
n3_bitlen = (int)bitlen_bignum(n3, n4_len);
|
||||
n3_len = (uint)((n3_bitlen + 31) / 32);
|
||||
bit_mask = (((uint)1) << ((n3_bitlen - 1) % 32)) >> 1;
|
||||
pn3 += n3_len - 1;
|
||||
n3_bitlen--;
|
||||
mov_bignum(n1, n2, n4_len);
|
||||
while (--n3_bitlen != -1)
|
||||
{
|
||||
if (bit_mask == 0)
|
||||
{
|
||||
bit_mask = 0x80000000;
|
||||
pn3--;
|
||||
}
|
||||
calc_a_bignum(n_tmp, n1, n1, n4_len);
|
||||
if ((*pn3 & bit_mask) != 0)
|
||||
calc_a_bignum(n1, n_tmp, n2, n4_len);
|
||||
else
|
||||
mov_bignum(n1, n_tmp, n4_len);
|
||||
bit_mask >>= 1;
|
||||
}
|
||||
init_bignum(n_tmp, 0, n4_len);
|
||||
clear_tmp_vars(len);
|
||||
}
|
||||
}
|
||||
}
|
||||
init_bignum(n1, 1, len);
|
||||
n4_len = len_bignum(n4, len);
|
||||
init_two_dw(n4, n4_len);
|
||||
n3_bitlen = (int)bitlen_bignum(n3, n4_len);
|
||||
n3_len = (uint)((n3_bitlen + 31) / 32);
|
||||
bit_mask = (((uint)1) << ((n3_bitlen - 1) % 32)) >> 1;
|
||||
pn3 += n3_len - 1;
|
||||
n3_bitlen--;
|
||||
mov_bignum(n1, n2, n4_len);
|
||||
while (--n3_bitlen != -1)
|
||||
{
|
||||
if (bit_mask == 0)
|
||||
{
|
||||
bit_mask = 0x80000000;
|
||||
pn3--;
|
||||
}
|
||||
calc_a_bignum(n_tmp, n1, n1, n4_len);
|
||||
if ((*pn3 & bit_mask) != 0)
|
||||
calc_a_bignum(n1, n_tmp, n2, n4_len);
|
||||
else
|
||||
mov_bignum(n1, n_tmp, n4_len);
|
||||
bit_mask >>= 1;
|
||||
}
|
||||
init_bignum(n_tmp, 0, n4_len);
|
||||
clear_tmp_vars(len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe void memcpy(byte* dest, byte* src, int len)
|
||||
{
|
||||
while (len-- != 0) *dest++ = *src++;
|
||||
}
|
||||
unsafe void memcpy(byte* dest, byte* src, int len)
|
||||
{
|
||||
while (len-- != 0) *dest++ = *src++;
|
||||
}
|
||||
|
||||
unsafe void process_predata(byte* pre, uint pre_len, byte *buf)
|
||||
{
|
||||
uint[] n2 = new uint[64];
|
||||
uint[] n3 = new uint[64];
|
||||
unsafe void process_predata(byte* pre, uint pre_len, byte *buf)
|
||||
{
|
||||
uint[] n2 = new uint[64];
|
||||
uint[] n3 = new uint[64];
|
||||
|
||||
uint a = (pubkey.len - 1) / 8;
|
||||
while (a + 1 <= pre_len)
|
||||
{
|
||||
init_bignum(n2, 0, 64);
|
||||
fixed( uint * pn2 = &n2[0] )
|
||||
memcpy((byte *)pn2, pre, (int)a + 1);
|
||||
calc_a_key(n3, n2, pubkey.key2, pubkey.key1, 64);
|
||||
uint a = (pubkey.len - 1) / 8;
|
||||
while (a + 1 <= pre_len)
|
||||
{
|
||||
init_bignum(n2, 0, 64);
|
||||
fixed( uint * pn2 = &n2[0] )
|
||||
memcpy((byte *)pn2, pre, (int)a + 1);
|
||||
calc_a_key(n3, n2, pubkey.key2, pubkey.key1, 64);
|
||||
|
||||
fixed( uint * pn3 = &n3[0] )
|
||||
memcpy(buf, (byte *)pn3, (int)a);
|
||||
fixed( uint * pn3 = &n3[0] )
|
||||
memcpy(buf, (byte *)pn3, (int)a);
|
||||
|
||||
pre_len -= a + 1;
|
||||
pre += a + 1;
|
||||
buf += a;
|
||||
}
|
||||
}
|
||||
pre_len -= a + 1;
|
||||
pre += a + 1;
|
||||
buf += a;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] DecryptKey(byte[] src)
|
||||
{
|
||||
init_pubkey();
|
||||
byte[] dest = new byte[256];
|
||||
public byte[] DecryptKey(byte[] src)
|
||||
{
|
||||
init_pubkey();
|
||||
byte[] dest = new byte[256];
|
||||
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* pdest = &dest[0])
|
||||
fixed (byte* psrc = &src[0])
|
||||
process_predata(psrc, len_predata(), pdest);
|
||||
}
|
||||
return dest.Take(56).ToArray();
|
||||
}
|
||||
}
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* pdest = &dest[0])
|
||||
fixed (byte* psrc = &src[0])
|
||||
process_predata(psrc, len_predata(), pdest);
|
||||
}
|
||||
return dest.Take(56).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -14,20 +14,20 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public static int DecodeInto( byte[] src, byte[] dest )
|
||||
{
|
||||
var ctx = new FastByteReader(src);
|
||||
var ctx = new FastByteReader(src);
|
||||
int destIndex = 0;
|
||||
|
||||
while( true )
|
||||
{
|
||||
byte i = ctx.ReadByte();
|
||||
byte i = ctx.ReadByte();
|
||||
if( ( i & 0x80 ) == 0 )
|
||||
{
|
||||
int count = i & 0x7F;
|
||||
if( count == 0 )
|
||||
{
|
||||
// case 6
|
||||
count = ctx.ReadByte();
|
||||
byte value = ctx.ReadByte();
|
||||
count = ctx.ReadByte();
|
||||
byte value = ctx.ReadByte();
|
||||
for( int end = destIndex + count ; destIndex < end ; destIndex++ )
|
||||
dest[ destIndex ] ^= value;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
// case 5
|
||||
for( int end = destIndex + count ; destIndex < end ; destIndex++ )
|
||||
dest[destIndex] ^= ctx.ReadByte();
|
||||
dest[destIndex] ^= ctx.ReadByte();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.FileFormats
|
||||
int count = i & 0x7F;
|
||||
if( count == 0 )
|
||||
{
|
||||
count = ctx.ReadWord();
|
||||
count = ctx.ReadWord();
|
||||
if( count == 0 )
|
||||
return destIndex;
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
// case 3
|
||||
for( int end = destIndex + ( count & 0x3FFF ) ; destIndex < end ; destIndex++ )
|
||||
dest[destIndex] ^= ctx.ReadByte();
|
||||
dest[destIndex] ^= ctx.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
// case 4
|
||||
byte value = ctx.ReadByte();
|
||||
byte value = ctx.ReadByte();
|
||||
for( int end = destIndex + ( count & 0x3FFF ) ; destIndex < end ; destIndex++ )
|
||||
dest[ destIndex ] ^= value;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -13,32 +13,32 @@ using System.IO;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
class FastByteReader
|
||||
{
|
||||
readonly byte[] src;
|
||||
int offset = 0;
|
||||
class FastByteReader
|
||||
{
|
||||
readonly byte[] src;
|
||||
int offset = 0;
|
||||
|
||||
public FastByteReader(byte[] src)
|
||||
{
|
||||
this.src = src;
|
||||
}
|
||||
public FastByteReader(byte[] src)
|
||||
{
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public bool Done() { return offset >= src.Length; }
|
||||
public byte ReadByte() { return src[offset++]; }
|
||||
public int ReadWord()
|
||||
{
|
||||
int x = ReadByte();
|
||||
return x | (ReadByte() << 8);
|
||||
}
|
||||
public bool Done() { return offset >= src.Length; }
|
||||
public byte ReadByte() { return src[offset++]; }
|
||||
public int ReadWord()
|
||||
{
|
||||
int x = ReadByte();
|
||||
return x | (ReadByte() << 8);
|
||||
}
|
||||
|
||||
public void CopyTo(byte[] dest, int offset, int count)
|
||||
{
|
||||
Array.Copy(src, this.offset, dest, offset, count);
|
||||
this.offset += count;
|
||||
}
|
||||
public void CopyTo(byte[] dest, int offset, int count)
|
||||
{
|
||||
Array.Copy(src, this.offset, dest, offset, count);
|
||||
this.offset += count;
|
||||
}
|
||||
|
||||
public int Remaining() { return src.Length - offset; }
|
||||
}
|
||||
}
|
||||
|
||||
public static class Format80
|
||||
{
|
||||
@@ -61,16 +61,16 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public static int DecodeInto( byte[] src, byte[] dest )
|
||||
{
|
||||
var ctx = new FastByteReader(src);
|
||||
var ctx = new FastByteReader(src);
|
||||
int destIndex = 0;
|
||||
|
||||
while( true )
|
||||
{
|
||||
byte i = ctx.ReadByte();
|
||||
byte i = ctx.ReadByte();
|
||||
if( ( i & 0x80 ) == 0 )
|
||||
{
|
||||
// case 2
|
||||
byte secondByte = ctx.ReadByte();
|
||||
byte secondByte = ctx.ReadByte();
|
||||
int count = ( ( i & 0x70 ) >> 4 ) + 3;
|
||||
int rpos = ( ( i & 0xf ) << 8 ) + secondByte;
|
||||
|
||||
@@ -93,8 +93,8 @@ namespace OpenRA.FileFormats
|
||||
if( count3 == 0x3E )
|
||||
{
|
||||
// case 4
|
||||
int count = ctx.ReadWord();
|
||||
byte color = ctx.ReadByte();
|
||||
int count = ctx.ReadWord();
|
||||
byte color = ctx.ReadByte();
|
||||
|
||||
for( int end = destIndex + count ; destIndex < end ; destIndex++ )
|
||||
dest[ destIndex ] = color;
|
||||
@@ -102,8 +102,8 @@ namespace OpenRA.FileFormats
|
||||
else if( count3 == 0x3F )
|
||||
{
|
||||
// case 5
|
||||
int count = ctx.ReadWord();
|
||||
int srcIndex = ctx.ReadWord();
|
||||
int count = ctx.ReadWord();
|
||||
int srcIndex = ctx.ReadWord();
|
||||
if( srcIndex >= destIndex )
|
||||
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
// case 3
|
||||
int count = count3 + 3;
|
||||
int srcIndex = ctx.ReadWord();
|
||||
int srcIndex = ctx.ReadWord();
|
||||
if( srcIndex >= destIndex )
|
||||
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
/* quick & dirty format80 encoder -- only uses raw copy operator, terminated with a zero-run. */
|
||||
/* this does not produce good compression, but it's valid format80 */
|
||||
|
||||
|
||||
var ctx = new FastByteReader(src);
|
||||
var ms = new MemoryStream();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -38,46 +38,46 @@ namespace OpenRA.FileFormats
|
||||
|
||||
static IFolder OpenPackage(string filename)
|
||||
{
|
||||
return OpenPackage(filename, order++);
|
||||
return OpenPackage(filename, order++);
|
||||
}
|
||||
|
||||
public static IFolder CreatePackage(string filename, int order, Dictionary<string, byte[]> content)
|
||||
{
|
||||
{
|
||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new MixFile(filename, order, content);
|
||||
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order, content);
|
||||
else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order, content);
|
||||
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
||||
throw new NotImplementedException("Creating .Z archives is unsupported");
|
||||
else
|
||||
return new Folder(filename, order, content);
|
||||
}
|
||||
|
||||
public static IFolder OpenPackage(string filename, int order)
|
||||
{
|
||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new MixFile(filename, order);
|
||||
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order);
|
||||
else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order);
|
||||
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new InstallShieldPackage(filename, order);
|
||||
else
|
||||
return new Folder(filename, order);
|
||||
}
|
||||
return new MixFile(filename, order, content);
|
||||
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order, content);
|
||||
else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order, content);
|
||||
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
||||
throw new NotImplementedException("Creating .Z archives is unsupported");
|
||||
else
|
||||
return new Folder(filename, order, content);
|
||||
}
|
||||
|
||||
public static IFolder OpenPackage(string filename, int order)
|
||||
{
|
||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new MixFile(filename, order);
|
||||
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order);
|
||||
else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new ZipFile(filename, order);
|
||||
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
||||
return new InstallShieldPackage(filename, order);
|
||||
else
|
||||
return new Folder(filename, order);
|
||||
}
|
||||
|
||||
public static void Mount(string name)
|
||||
{
|
||||
var optional = name.StartsWith("~");
|
||||
if (optional) name = name.Substring(1);
|
||||
|
||||
|
||||
// paths starting with ^ are relative to the support dir
|
||||
if (name.StartsWith("^"))
|
||||
name = Platform.SupportDir+name.Substring(1);
|
||||
|
||||
|
||||
var a = (Action)(() => FileSystem.MountInner(OpenPackage(name)));
|
||||
|
||||
if (optional)
|
||||
@@ -169,7 +169,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
foreach (var folder in mountedFolders)
|
||||
if (folder.Exists(filename))
|
||||
return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace OpenRA.FileFormats
|
||||
assemblyCache.Add(filename, a);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -27,10 +27,10 @@ namespace OpenRA.FileFormats
|
||||
this.priority = priority;
|
||||
if (Directory.Exists(path))
|
||||
Directory.Delete(path, true);
|
||||
|
||||
|
||||
Write(contents);
|
||||
}
|
||||
|
||||
|
||||
public Folder(string path, int priority)
|
||||
{
|
||||
this.path = path;
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.FileFormats
|
||||
foreach( var filename in Directory.GetFiles( path, "*", SearchOption.TopDirectoryOnly ) )
|
||||
yield return PackageEntry.HashFilename( Path.GetFileName(filename) );
|
||||
}
|
||||
|
||||
|
||||
public bool Exists(string filename)
|
||||
{
|
||||
return File.Exists(Path.Combine(path,filename));
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
get { return priority; }
|
||||
}
|
||||
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.FileFormats
|
||||
foreach (var file in contents)
|
||||
using (var dataStream = File.Create(Path.Combine(path, file.Key)))
|
||||
using (var writer = new BinaryWriter(dataStream))
|
||||
writer.Write(file.Value);
|
||||
writer.Write(file.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.FileFormats
|
||||
uint signature = reader.ReadUInt32();
|
||||
if (signature != 0x8C655D13)
|
||||
throw new InvalidDataException("Not an Installshield package");
|
||||
|
||||
|
||||
reader.ReadBytes(8);
|
||||
/*var FileCount = */reader.ReadUInt16();
|
||||
reader.ReadBytes(4);
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.FileFormats
|
||||
var TOCAddress = reader.ReadInt32();
|
||||
reader.ReadBytes(4);
|
||||
var DirCount = reader.ReadUInt16();
|
||||
|
||||
|
||||
// Parse the directory list
|
||||
s.Seek(TOCAddress, SeekOrigin.Begin);
|
||||
BinaryReader TOCreader = new BinaryReader(s);
|
||||
@@ -56,15 +56,15 @@ namespace OpenRA.FileFormats
|
||||
var ChunkSize = reader.ReadUInt16();
|
||||
var NameLength = reader.ReadUInt16();
|
||||
reader.ReadChars(NameLength); //var DirName = new String(reader.ReadChars(NameLength));
|
||||
|
||||
|
||||
// Skip to the end of the chunk
|
||||
reader.ReadBytes(ChunkSize - NameLength - 6);
|
||||
|
||||
|
||||
// Parse files
|
||||
for (var i = 0; i < FileCount; i++)
|
||||
ParseFile(reader);
|
||||
}
|
||||
|
||||
|
||||
uint AccumulatedData = 0;
|
||||
void ParseFile(BinaryReader reader)
|
||||
{
|
||||
@@ -79,11 +79,11 @@ namespace OpenRA.FileFormats
|
||||
var hash = PackageEntry.HashFilename(FileName);
|
||||
index.Add(hash, new PackageEntry(hash,AccumulatedData, CompressedSize));
|
||||
AccumulatedData += CompressedSize;
|
||||
|
||||
|
||||
// Skip to the end of the chunk
|
||||
reader.ReadBytes(ChunkSize - NameLength - 30);
|
||||
}
|
||||
|
||||
|
||||
public Stream GetContent(uint hash)
|
||||
{
|
||||
PackageEntry e;
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.FileFormats
|
||||
s.Seek( dataStart + e.Offset, SeekOrigin.Begin );
|
||||
byte[] data = new byte[ e.Length ];
|
||||
s.Read( data, 0, (int)e.Length );
|
||||
|
||||
|
||||
return new MemoryStream(Blast.Decompress(data));
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
return index.Keys;
|
||||
}
|
||||
|
||||
|
||||
public bool Exists(string filename)
|
||||
{
|
||||
return index.ContainsKey(PackageEntry.HashFilename(filename));
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
get { return 2000 + priority; }
|
||||
}
|
||||
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
throw new NotImplementedException("Cannot save InstallShieldPackages.");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -31,14 +31,14 @@ namespace OpenRA.FileFormats
|
||||
readonly long dataStart;
|
||||
readonly Stream s;
|
||||
int priority;
|
||||
|
||||
|
||||
// Create a new MixFile
|
||||
public MixFile(string filename, int priority, Dictionary<string, byte[]> contents)
|
||||
{
|
||||
this.priority = priority;
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
|
||||
|
||||
s = File.Create(filename);
|
||||
Write(contents);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace OpenRA.FileFormats
|
||||
dataStart = s.Position;
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public Stream GetContent(uint hash)
|
||||
{
|
||||
PackageEntry e;
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
return index.Keys;
|
||||
}
|
||||
|
||||
|
||||
public bool Exists(string filename)
|
||||
{
|
||||
return index.ContainsKey(PackageEntry.HashFilename(filename));
|
||||
@@ -170,17 +170,17 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
get { return 1000 + priority; }
|
||||
}
|
||||
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
// Cannot modify existing mixfile - rename existing file and
|
||||
// create a new one with original content plus modifications
|
||||
FileSystem.Unmount(this);
|
||||
|
||||
|
||||
// TODO: Add existing data to the contents list
|
||||
if (index.Count > 0)
|
||||
throw new NotImplementedException("Updating mix files unfinished");
|
||||
|
||||
|
||||
// Construct a list of entries for the file header
|
||||
uint dataSize = 0;
|
||||
var items = new List<PackageEntry>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
|
||||
|
||||
pkg = SZipFile.Create(filename);
|
||||
Write(contents);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.FileFormats
|
||||
foreach(ZipEntry entry in pkg)
|
||||
yield return PackageEntry.HashFilename(entry.Name);
|
||||
}
|
||||
|
||||
|
||||
public bool Exists(string filename)
|
||||
{
|
||||
return pkg.GetEntry(filename) != null;
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
get { return 500 + priority; }
|
||||
}
|
||||
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
pkg.Close();
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public Stream GetSource()
|
||||
{
|
||||
return new MemoryStream(data);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -83,14 +83,14 @@ namespace OpenRA.FileFormats
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
|
||||
ImageCount = reader.ReadUInt16();
|
||||
|
||||
|
||||
//Last offset is pointer to end of file.
|
||||
uint[] offsets = new uint[ImageCount + 1];
|
||||
|
||||
uint temp = reader.ReadUInt32();
|
||||
|
||||
//If fourth byte in file is non-zero, the offsets are two bytes each.
|
||||
bool twoByteOffsets = (temp & 0xFF0000) > 0;
|
||||
bool twoByteOffsets = (temp & 0xFF0000) > 0;
|
||||
if (twoByteOffsets)
|
||||
{
|
||||
offsets[0] = ((temp & 0xFFFF0000) >> 16) + 2; //Offset does not account for image count bytes
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
get { return headers[index]; }
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator<Dune2ImageHeader> GetEnumerator()
|
||||
{
|
||||
return headers.GetEnumerator();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.FileFormats.Graphics
|
||||
|
||||
public interface IDeviceFactory
|
||||
{
|
||||
IGraphicsDevice Create( Size size, WindowMode windowMode );
|
||||
IGraphicsDevice Create( Size size, WindowMode windowMode );
|
||||
}
|
||||
|
||||
public interface IGraphicsDevice
|
||||
@@ -73,20 +73,20 @@ namespace OpenRA.FileFormats.Graphics
|
||||
void SetData(byte[] colors, int width, int height);
|
||||
}
|
||||
|
||||
public enum PrimitiveType
|
||||
{
|
||||
PointList,
|
||||
LineList,
|
||||
TriangleList,
|
||||
public enum PrimitiveType
|
||||
{
|
||||
PointList,
|
||||
LineList,
|
||||
TriangleList,
|
||||
QuadList,
|
||||
}
|
||||
}
|
||||
|
||||
public struct Range<T>
|
||||
{
|
||||
public readonly T Start, End;
|
||||
public Range( T start, T end ) { Start = start; End = end; }
|
||||
}
|
||||
|
||||
|
||||
public enum WindowMode
|
||||
{
|
||||
Windowed,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -27,13 +27,15 @@ namespace OpenRA
|
||||
public MouseButton Button;
|
||||
public int2 Location;
|
||||
public Modifiers Modifiers;
|
||||
public int MultiTapCount;
|
||||
|
||||
public MouseInput( MouseInputEvent ev, MouseButton button, int2 location, Modifiers mods )
|
||||
public MouseInput( MouseInputEvent ev, MouseButton button, int2 location, Modifiers mods, int multiTapCount )
|
||||
{
|
||||
this.Event = ev;
|
||||
this.Button = button;
|
||||
this.Location = location;
|
||||
this.Modifiers = mods;
|
||||
this.MultiTapCount = multiTapCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,5 +70,6 @@ namespace OpenRA
|
||||
public string KeyName;
|
||||
public Modifiers Modifiers;
|
||||
public int VirtKey;
|
||||
public int MultiTapCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.FileFormats
|
||||
public readonly byte Framerate;
|
||||
public readonly ushort Width;
|
||||
public readonly ushort Height;
|
||||
|
||||
|
||||
Stream stream;
|
||||
int currentFrame;
|
||||
ushort numColors;
|
||||
@@ -32,75 +32,75 @@ namespace OpenRA.FileFormats
|
||||
|
||||
// Stores a list of subpixels, referenced by the VPTZ chunk
|
||||
byte[] cbf;
|
||||
byte[] cbp;
|
||||
byte[] cbp;
|
||||
int cbChunk = 0;
|
||||
int cbOffset = 0;
|
||||
|
||||
|
||||
// Top half contains block info, bottom half contains references to cbf array
|
||||
byte[] origData;
|
||||
|
||||
|
||||
// Final frame output
|
||||
uint[,] frameData;
|
||||
byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed.
|
||||
|
||||
public byte[] AudioData { get { return audioData; } }
|
||||
public int CurrentFrame { get { return currentFrame; } }
|
||||
|
||||
|
||||
public VqaReader( Stream stream )
|
||||
{
|
||||
this.stream = stream;
|
||||
BinaryReader reader = new BinaryReader( stream );
|
||||
|
||||
|
||||
// Decode FORM chunk
|
||||
if (new String(reader.ReadChars(4)) != "FORM")
|
||||
throw new InvalidDataException("Invalid vqa (invalid FORM section)");
|
||||
/*var length = */ reader.ReadUInt32();
|
||||
|
||||
|
||||
if (new String(reader.ReadChars(8)) != "WVQAVQHD")
|
||||
throw new InvalidDataException("Invalid vqa (not WVQAVQHD)");
|
||||
/* var length = */reader.ReadUInt32();
|
||||
|
||||
|
||||
/*var version = */reader.ReadUInt16();
|
||||
/*var flags = */reader.ReadUInt16();
|
||||
Frames = reader.ReadUInt16();
|
||||
Width = reader.ReadUInt16();
|
||||
Height = reader.ReadUInt16();
|
||||
|
||||
|
||||
blockWidth = reader.ReadByte();
|
||||
blockHeight = reader.ReadByte();
|
||||
Framerate = reader.ReadByte();
|
||||
cbParts = reader.ReadByte();
|
||||
blocks = new int2(Width / blockWidth, Height / blockHeight);
|
||||
|
||||
|
||||
numColors = reader.ReadUInt16();
|
||||
/*var maxBlocks = */reader.ReadUInt16();
|
||||
/*var unknown1 = */reader.ReadUInt16();
|
||||
/*var unknown2 = */reader.ReadUInt32();
|
||||
|
||||
|
||||
// Audio
|
||||
/*var freq = */reader.ReadUInt16();
|
||||
/*var channels = */reader.ReadByte();
|
||||
/*var bits = */reader.ReadByte();
|
||||
/*var unknown3 = */reader.ReadChars(14);
|
||||
|
||||
|
||||
|
||||
|
||||
var frameSize = Exts.NextPowerOf2(Math.Max(Width,Height));
|
||||
cbf = new byte[Width*Height];
|
||||
cbp = new byte[Width*Height];
|
||||
palette = new uint[numColors];
|
||||
origData = new byte[2*blocks.X*blocks.Y];
|
||||
frameData = new uint[frameSize,frameSize];
|
||||
|
||||
|
||||
var type = new String(reader.ReadChars(4));
|
||||
if (type != "FINF")
|
||||
{
|
||||
reader.ReadBytes(27);
|
||||
type = new String(reader.ReadChars(4));
|
||||
}
|
||||
|
||||
|
||||
/*var length = */reader.ReadUInt16();
|
||||
/*var unknown4 = */reader.ReadUInt16();
|
||||
|
||||
|
||||
// Frame offsets
|
||||
offsets = new UInt32[Frames];
|
||||
for (int i = 0; i < Frames; i++)
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
CollectAudioData();
|
||||
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace OpenRA.FileFormats
|
||||
currentFrame = cbOffset = cbChunk = 0;
|
||||
LoadFrame();
|
||||
}
|
||||
|
||||
|
||||
void CollectAudioData()
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
@@ -163,17 +163,17 @@ namespace OpenRA.FileFormats
|
||||
currentFrame++;
|
||||
LoadFrame();
|
||||
}
|
||||
|
||||
|
||||
void LoadFrame()
|
||||
{
|
||||
{
|
||||
if (currentFrame >= Frames)
|
||||
return;
|
||||
|
||||
|
||||
// Seek to the start of the frame
|
||||
stream.Seek(offsets[currentFrame], SeekOrigin.Begin);
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
var end = (currentFrame < Frames - 1) ? offsets[currentFrame+1] : stream.Length;
|
||||
|
||||
|
||||
while(reader.BaseStream.Position < end)
|
||||
{
|
||||
var type = new String(reader.ReadChars(4));
|
||||
@@ -189,17 +189,17 @@ namespace OpenRA.FileFormats
|
||||
reader.ReadBytes((int)length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Chunks are aligned on even bytes; advance by a byte if the next one is null
|
||||
if (reader.PeekChar() == 0) reader.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// VQA Frame
|
||||
public void DecodeVQFR(BinaryReader reader)
|
||||
{
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
{
|
||||
// Chunks are aligned on even bytes; may be padded with a single null
|
||||
if (reader.PeekChar() == 0) reader.ReadByte();
|
||||
var type = new String(reader.ReadChars(4));
|
||||
@@ -214,9 +214,9 @@ namespace OpenRA.FileFormats
|
||||
case "CBF0":
|
||||
cbf = reader.ReadBytes(subchunkLength);
|
||||
break;
|
||||
|
||||
|
||||
// frame-modifier chunk
|
||||
case "CBP0":
|
||||
case "CBP0":
|
||||
case "CBPZ":
|
||||
// Partial buffer is full; dump and recreate
|
||||
if (cbChunk == cbParts)
|
||||
@@ -225,16 +225,16 @@ namespace OpenRA.FileFormats
|
||||
cbf = (byte[])cbp.Clone();
|
||||
else
|
||||
Format80.DecodeInto( cbp, cbf );
|
||||
|
||||
|
||||
cbOffset = cbChunk = 0;
|
||||
}
|
||||
|
||||
|
||||
var bytes = reader.ReadBytes(subchunkLength);
|
||||
bytes.CopyTo(cbp,cbOffset);
|
||||
cbOffset += subchunkLength;
|
||||
cbChunk++;
|
||||
break;
|
||||
|
||||
|
||||
// Palette
|
||||
case "CPL0":
|
||||
for (int i = 0; i < numColors; i++)
|
||||
@@ -245,7 +245,7 @@ namespace OpenRA.FileFormats
|
||||
palette[i] = (uint)((255 << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// Frame data
|
||||
case "VPTZ":
|
||||
Format80.DecodeInto( reader.ReadBytes(subchunkLength), origData );
|
||||
@@ -256,7 +256,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cachedFrame = -1;
|
||||
|
||||
void DecodeFrameData( int frame )
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
public static class HttpUtil
|
||||
{
|
||||
public static byte[] DownloadData(string url, Action<int, int> f, int chunkSize)
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
var ip = Dns.GetHostEntry(uri.DnsSafeHost).AddressList[0];
|
||||
|
||||
using (var s = new TcpClient())
|
||||
{
|
||||
s.Connect(new IPEndPoint(ip, uri.Port));
|
||||
var ns = s.GetStream();
|
||||
var sw = new StreamWriter(ns);
|
||||
|
||||
sw.Write("GET {0} HTTP/1.0\r\nHost:{1}\r\n\r\n", uri.PathAndQuery, uri.Host);
|
||||
sw.Flush();
|
||||
|
||||
var br = new BinaryReader(ns);
|
||||
var contentLength = 0;
|
||||
var offset = 0;
|
||||
for (; ; )
|
||||
{
|
||||
var result = br.ReadLine();
|
||||
var kv = result.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (result == "")
|
||||
{
|
||||
/* data follows the blank line */
|
||||
|
||||
if (contentLength > 0)
|
||||
{
|
||||
if (f != null)
|
||||
f(offset, contentLength);
|
||||
|
||||
var data = new byte[contentLength];
|
||||
while (offset < contentLength)
|
||||
{
|
||||
var thisChunk = Math.Min(contentLength - offset, chunkSize);
|
||||
br.Read(data, offset, thisChunk);
|
||||
offset += thisChunk;
|
||||
if (f != null)
|
||||
f(offset, contentLength);
|
||||
}
|
||||
s.Close();
|
||||
return data;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Close();
|
||||
return new byte[] { };
|
||||
}
|
||||
}
|
||||
else if (kv[0] == "Content-Length")
|
||||
contentLength = int.Parse(kv[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] DownloadData(string url, Action<int, int> f)
|
||||
{
|
||||
return DownloadData(url, f, 4096);
|
||||
}
|
||||
|
||||
public static byte[] DownloadData(string url)
|
||||
{
|
||||
return DownloadData(url, null);
|
||||
}
|
||||
|
||||
static string ReadLine(this BinaryReader br)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
char c;
|
||||
while ((c = br.ReadChar()) != '\n')
|
||||
if (c != '\r' && c != '\n')
|
||||
sb.Append(c);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
if (!Directory.Exists(destPath))
|
||||
Directory.CreateDirectory(destPath);
|
||||
|
||||
|
||||
if (!Directory.Exists(srcPath)) { onError("Cannot find "+package); return false; }
|
||||
FileSystem.Mount(srcPath);
|
||||
if (!FileSystem.Exists(package)) { onError("Cannot find "+package); return false; }
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool CopyFiles(string srcPath, string[] files, string destPath, Action<string> onProgress, Action<string> onError)
|
||||
{
|
||||
foreach (var file in files)
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool ExtractZip(string zipFile, string dest, Action<string> onProgress, Action<string> onError)
|
||||
{
|
||||
if (!File.Exists(zipFile))
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.FileFormats
|
||||
onError("Invalid path: "+zipFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
List<string> extracted = new List<string>();
|
||||
try
|
||||
{
|
||||
@@ -96,26 +96,26 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
foreach(var f in extracted)
|
||||
File.Delete(f);
|
||||
|
||||
|
||||
onError("Invalid archive");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TODO: this belongs in FileSystem/ZipFile
|
||||
static void ExtractZip(this ZipInputStream z, string destPath, List<string> extracted, Action<string> onProgress)
|
||||
{
|
||||
foreach (var entry in z.GetEntries())
|
||||
{
|
||||
if (!entry.IsFile) continue;
|
||||
|
||||
|
||||
onProgress(entry.Name);
|
||||
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
|
||||
var path = Path.Combine(destPath, entry.Name);
|
||||
extracted.Add(path);
|
||||
|
||||
|
||||
using (var f = File.Create(path))
|
||||
{
|
||||
int bufSize = 2048;
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.FileFormats
|
||||
f.Write(buf, 0, bufSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
z.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -48,10 +48,10 @@ namespace OpenRA.FileFormats
|
||||
Movies = YamlList(yaml, "Movies");
|
||||
TileSets = YamlList(yaml, "TileSets");
|
||||
ChromeMetrics = YamlList(yaml, "ChromeMetrics");
|
||||
|
||||
|
||||
LoadScreen = yaml["LoadScreen"];
|
||||
Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value,
|
||||
int.Parse(x.Value.NodesDict["Size"].Value)));
|
||||
int.Parse(x.Value.NodesDict["Size"].Value)));
|
||||
if (yaml.ContainsKey("TileSize"))
|
||||
TileSize = int.Parse(yaml["TileSize"].Value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.FileFormats
|
||||
public string Race;
|
||||
|
||||
public bool LockColor = false;
|
||||
public ColorRamp ColorRamp = new ColorRamp(0,0,238,34);
|
||||
public ColorRamp ColorRamp = new ColorRamp(0,0,238,34);
|
||||
|
||||
public bool LockSpawn = false;
|
||||
public int Spawn = 0;
|
||||
@@ -39,11 +39,10 @@ namespace OpenRA.FileFormats
|
||||
public int InitialCash = 0;
|
||||
public string[] Allies = {};
|
||||
public string[] Enemies = {};
|
||||
|
||||
|
||||
public PlayerReference() {}
|
||||
public PlayerReference(MiniYaml my)
|
||||
{
|
||||
FieldLoader.Load(this, my);
|
||||
}
|
||||
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||
|
||||
public override string ToString() { return Name; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.FileFormats
|
||||
Location = location;
|
||||
Depth = depth;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format("{0} {1},{2} {3}", Type, Location.X,Location.Y, Depth);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -18,35 +18,35 @@ namespace OpenRA.FileFormats
|
||||
public readonly List<byte[]> TileBitmapBytes = new List<byte[]>();
|
||||
|
||||
public Terrain( Stream stream, int size )
|
||||
{
|
||||
{
|
||||
// Try loading as a cnc .tem
|
||||
BinaryReader reader = new BinaryReader( stream );
|
||||
int Width = reader.ReadUInt16();
|
||||
int Height = reader.ReadUInt16();
|
||||
|
||||
|
||||
if( Width != size || Height != size )
|
||||
throw new InvalidDataException( "{0}x{1} != {2}x{2}".F(Width, Height, size ) );
|
||||
|
||||
|
||||
/*NumTiles = */reader.ReadUInt16();
|
||||
/*Zero1 = */reader.ReadUInt16();
|
||||
/*Zero1 = */reader.ReadUInt16();
|
||||
/*uint Size = */reader.ReadUInt32();
|
||||
uint ImgStart = reader.ReadUInt32();
|
||||
/*Zero2 = */reader.ReadUInt32();
|
||||
|
||||
|
||||
int IndexEnd, IndexStart;
|
||||
if (reader.ReadUInt16() == 65535) // ID1 = FFFFh for cnc
|
||||
{
|
||||
/*ID2 = */reader.ReadUInt16();
|
||||
/*ID2 = */reader.ReadUInt16();
|
||||
IndexEnd = reader.ReadInt32();
|
||||
IndexStart = reader.ReadInt32();
|
||||
}
|
||||
else // Load as a ra .tem
|
||||
{
|
||||
stream.Position = 0;
|
||||
stream.Position = 0;
|
||||
reader = new BinaryReader( stream );
|
||||
Width = reader.ReadUInt16();
|
||||
Height = reader.ReadUInt16();
|
||||
|
||||
|
||||
/*NumTiles = */reader.ReadUInt16();
|
||||
reader.ReadUInt16();
|
||||
/*XDim = */reader.ReadUInt16();
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.FileFormats
|
||||
reader.ReadUInt32();
|
||||
IndexEnd = reader.ReadInt32();
|
||||
reader.ReadUInt32();
|
||||
IndexStart = reader.ReadInt32();
|
||||
IndexStart = reader.ReadInt32();
|
||||
}
|
||||
stream.Position = IndexStart;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -14,7 +14,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public T type;
|
||||
public U index;
|
||||
|
||||
|
||||
public TileReference(T t, U i)
|
||||
{
|
||||
type = t;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -25,9 +26,10 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public TerrainTypeInfo() {}
|
||||
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
|
||||
|
||||
public MiniYaml Save() { return FieldSaver.Save(this); }
|
||||
}
|
||||
|
||||
|
||||
public class TileTemplate
|
||||
{
|
||||
public ushort Id;
|
||||
@@ -37,12 +39,9 @@ namespace OpenRA.FileFormats
|
||||
|
||||
[FieldLoader.LoadUsing( "LoadTiles" )]
|
||||
public Dictionary<byte, string> Tiles = new Dictionary<byte, string>();
|
||||
|
||||
|
||||
public TileTemplate() {}
|
||||
public TileTemplate(MiniYaml my)
|
||||
{
|
||||
FieldLoader.Load( this, my );
|
||||
}
|
||||
public TileTemplate(MiniYaml my) { FieldLoader.Load( this, my ); }
|
||||
|
||||
static object LoadTiles( MiniYaml y )
|
||||
{
|
||||
@@ -50,11 +49,13 @@ namespace OpenRA.FileFormats
|
||||
t => byte.Parse(t.Key),
|
||||
t => t.Value.Value );
|
||||
}
|
||||
|
||||
|
||||
static readonly string[] Fields = { "Id", "Image", "Size", "PickAny" };
|
||||
|
||||
public MiniYaml Save()
|
||||
{
|
||||
var root = new List<MiniYamlNode>();
|
||||
foreach (var field in new string[] {"Id", "Image", "Size", "PickAny"})
|
||||
foreach (var field in Fields)
|
||||
{
|
||||
FieldInfo f = this.GetType().GetField(field);
|
||||
if (f.GetValue(this) == null) continue;
|
||||
@@ -63,11 +64,13 @@ namespace OpenRA.FileFormats
|
||||
|
||||
root.Add( new MiniYamlNode( "Tiles", null,
|
||||
Tiles.Select( x => new MiniYamlNode( x.Key.ToString(), x.Value ) ).ToList() ) );
|
||||
|
||||
|
||||
return new MiniYaml(null, root);
|
||||
}
|
||||
|
||||
public Terrain Data;
|
||||
}
|
||||
|
||||
|
||||
public class TileSet
|
||||
{
|
||||
public string Name;
|
||||
@@ -76,15 +79,16 @@ namespace OpenRA.FileFormats
|
||||
public int TileSize = 24;
|
||||
public string[] Extensions;
|
||||
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
||||
public Dictionary<ushort, Terrain> Tiles = new Dictionary<ushort, Terrain>();
|
||||
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||
static List<string> fields = new List<string>() {"Name", "TileSize", "Id", "Palette", "Extensions"};
|
||||
|
||||
static readonly string[] fields = {"Name", "TileSize", "Id", "Palette", "Extensions"};
|
||||
|
||||
public TileSet() {}
|
||||
|
||||
public TileSet( string filepath )
|
||||
{
|
||||
var yaml = MiniYaml.DictFromFile( filepath );
|
||||
|
||||
|
||||
// General info
|
||||
FieldLoader.Load(this, yaml["General"]);
|
||||
|
||||
@@ -96,30 +100,30 @@ namespace OpenRA.FileFormats
|
||||
Templates = yaml["Templates"].NodesDict.Values
|
||||
.Select(y => new TileTemplate(y)).ToDictionary(t => t.Id);
|
||||
}
|
||||
|
||||
|
||||
public void LoadTiles()
|
||||
{
|
||||
foreach (var t in Templates)
|
||||
using( Stream s = FileSystem.OpenWithExts(t.Value.Image, Extensions) )
|
||||
{
|
||||
if( !Tiles.ContainsKey( t.Key ) )
|
||||
Tiles.Add( t.Key, new Terrain( s, TileSize ) );
|
||||
}
|
||||
if (t.Value.Data == null)
|
||||
using( var s = FileSystem.OpenWithExts(t.Value.Image, Extensions) )
|
||||
t.Value.Data = new Terrain(s, TileSize);
|
||||
}
|
||||
|
||||
|
||||
public void Save(string filepath)
|
||||
{
|
||||
{
|
||||
var root = new List<MiniYamlNode>();
|
||||
var gen = new List<MiniYamlNode>();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
FieldInfo f = this.GetType().GetField(field);
|
||||
if (f.GetValue(this) == null) continue;
|
||||
gen.Add( new MiniYamlNode( field, FieldSaver.FormatValue( this, f ) ) );
|
||||
}
|
||||
|
||||
root.Add( new MiniYamlNode( "General", null, gen ) );
|
||||
|
||||
root.Add( new MiniYamlNode( "Terrain", null,
|
||||
root.Add( new MiniYamlNode( "Terrain", null,
|
||||
Terrain.Select( t => new MiniYamlNode(
|
||||
"TerrainType@{0}".F( t.Value.Type ),
|
||||
t.Value.Save() ) ).ToList() ) );
|
||||
@@ -129,14 +133,14 @@ namespace OpenRA.FileFormats
|
||||
"Template@{0}".F( t.Value.Id ),
|
||||
t.Value.Save() ) ).ToList() ) );
|
||||
root.WriteToFile(filepath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public byte[] GetBytes(TileReference<ushort,byte> r)
|
||||
{
|
||||
Terrain tile;
|
||||
if( Tiles.TryGetValue( r.type, out tile ) )
|
||||
return tile.TileBitmapBytes[ r.index ];
|
||||
|
||||
TileTemplate tile;
|
||||
if( Templates.TryGetValue( r.type, out tile ) )
|
||||
return tile.Data.TileBitmapBytes[ r.index ];
|
||||
|
||||
byte[] missingTile = new byte[ TileSize * TileSize ];
|
||||
for( int i = 0 ; i < missingTile.Length ; i++ )
|
||||
missingTile[ i ] = 0x36;
|
||||
@@ -152,5 +156,43 @@ namespace OpenRA.FileFormats
|
||||
return "Clear"; // Default walkable
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Bitmap RenderTemplate(ushort n, Palette p)
|
||||
{
|
||||
var template = Templates[n];
|
||||
|
||||
var bitmap = new Bitmap(TileSize * template.Size.X, TileSize * template.Size.Y,
|
||||
PixelFormat.Format8bppIndexed);
|
||||
|
||||
bitmap.Palette = p.AsSystemPalette();
|
||||
|
||||
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
|
||||
unsafe
|
||||
{
|
||||
byte* q = (byte*)data.Scan0.ToPointer();
|
||||
var stride = data.Stride;
|
||||
|
||||
for (var u = 0; u < template.Size.X; u++)
|
||||
for (var v = 0; v < template.Size.Y; v++)
|
||||
if (template.Data.TileBitmapBytes[u + v * template.Size.X] != null)
|
||||
{
|
||||
var rawImage = template.Data.TileBitmapBytes[u + v * template.Size.X];
|
||||
for (var i = 0; i < TileSize; i++)
|
||||
for (var j = 0; j < TileSize; j++)
|
||||
q[(v * TileSize + j) * stride + u * TileSize + i] = rawImage[i + TileSize * j];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < TileSize; i++)
|
||||
for (var j = 0; j < TileSize; j++)
|
||||
q[(v * TileSize + j) * stride + u * TileSize + i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bitmap.UnlockBits(data);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.FileFormats
|
||||
public struct SourceLocation
|
||||
{
|
||||
public string Filename; public int Line;
|
||||
public override string ToString() { return "{0}:{1}".F(Filename, Line); }
|
||||
public override string ToString() { return "{0}:{1}".F(Filename, Line); }
|
||||
}
|
||||
|
||||
public SourceLocation Location;
|
||||
@@ -55,10 +55,10 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{YamlNode: {0} @ {1}}}".F(Key, Location);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return "{{YamlNode: {0} @ {1}}}".F(Key, Location);
|
||||
}
|
||||
}
|
||||
|
||||
public class MiniYaml
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
return new MiniYaml( null, list.Select( x => new MiniYamlNode( x.ToString(), new MiniYaml( null ) ) ).ToList() );
|
||||
}
|
||||
|
||||
|
||||
static List<MiniYamlNode> FromLines(string[] lines, string filename)
|
||||
{
|
||||
var levels = new List<List<MiniYamlNode>>();
|
||||
@@ -121,7 +121,7 @@ namespace OpenRA.FileFormats
|
||||
var d = new List<MiniYamlNode>();
|
||||
var rhs = SplitAtColon( ref t );
|
||||
levels[ level ].Add( new MiniYamlNode( t, rhs, d, new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo } ) );
|
||||
|
||||
|
||||
levels.Add(d);
|
||||
}
|
||||
return levels[ 0 ];
|
||||
@@ -143,11 +143,11 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
StreamReader reader = new StreamReader( FileSystem.Open(path) );
|
||||
List<string> lines = new List<string>();
|
||||
|
||||
|
||||
while( !reader.EndOfStream )
|
||||
lines.Add(reader.ReadLine());
|
||||
reader.Close();
|
||||
|
||||
|
||||
return FromLines(lines.ToArray(), path);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> FromFile( string path )
|
||||
{
|
||||
{
|
||||
return FromLines(File.ReadAllLines( path ), path);
|
||||
}
|
||||
|
||||
@@ -177,15 +177,15 @@ namespace OpenRA.FileFormats
|
||||
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), "<no filename available>");
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> MergeLiberal(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
public static List<MiniYamlNode> MergeLiberal(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
|
||||
public static List<MiniYamlNode> MergeStrict(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
public static List<MiniYamlNode> MergeStrict(List<MiniYamlNode> a, List<MiniYamlNode> b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
|
||||
static List<MiniYamlNode> Merge( List<MiniYamlNode> a, List<MiniYamlNode> b, bool throwErrors )
|
||||
{
|
||||
@@ -200,8 +200,8 @@ namespace OpenRA.FileFormats
|
||||
var bDict = b.ToDictionary( x => x.Key );
|
||||
var keys = aDict.Keys.Union( bDict.Keys ).ToList();
|
||||
|
||||
var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-')
|
||||
.ToDictionary(x => x.Substring(1), x => false);
|
||||
var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-')
|
||||
.ToDictionary(x => x.Substring(1), x => false);
|
||||
|
||||
foreach( var key in keys )
|
||||
{
|
||||
@@ -211,11 +211,11 @@ namespace OpenRA.FileFormats
|
||||
|
||||
if( noInherit.ContainsKey( key ) )
|
||||
{
|
||||
if (!throwErrors)
|
||||
if (aa != null)
|
||||
ret.Add(aa);
|
||||
if (!throwErrors)
|
||||
if (aa != null)
|
||||
ret.Add(aa);
|
||||
|
||||
noInherit[key] = true;
|
||||
noInherit[key] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,23 +225,23 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
if (throwErrors)
|
||||
if (noInherit.ContainsValue(false))
|
||||
throw new YamlException("Bogus yaml removals: {0}".F(
|
||||
string.Join(", ", noInherit.Where(x => !x.Value).Select(x => x.Key).ToArray())));
|
||||
if (throwErrors)
|
||||
if (noInherit.ContainsValue(false))
|
||||
throw new YamlException("Bogus yaml removals: {0}".F(
|
||||
noInherit.Where(x => !x.Value).JoinWith(", ")));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, false);
|
||||
}
|
||||
|
||||
public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b)
|
||||
{
|
||||
return Merge(a, b, true);
|
||||
}
|
||||
|
||||
static MiniYaml Merge( MiniYaml a, MiniYaml b, bool throwErrors )
|
||||
{
|
||||
@@ -271,9 +271,9 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public static string WriteToString(this MiniYamlNodes y)
|
||||
{
|
||||
return string.Join("\n", y.ToLines(true).Select(x => x.TrimEnd()).ToArray());
|
||||
return y.ToLines(true).Select(x => x.TrimEnd()).JoinWith("\n");
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<string> ToLines(this MiniYamlNodes y, bool lowest)
|
||||
{
|
||||
foreach (var kv in y)
|
||||
@@ -286,8 +286,8 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
public class YamlException : Exception
|
||||
{
|
||||
public YamlException(string s) : base(s) { }
|
||||
}
|
||||
public class YamlException : Exception
|
||||
{
|
||||
public YamlException(string s) : base(s) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
@@ -24,7 +22,6 @@ namespace OpenRA.FileFormats
|
||||
public string Version;
|
||||
public string Author;
|
||||
public string Requires;
|
||||
public bool Standalone = false;
|
||||
|
||||
public static readonly Dictionary<string, Mod> AllMods = ValidateMods(Directory.GetDirectories("mods").Select(x => x.Substring(5)).ToArray());
|
||||
|
||||
@@ -33,17 +30,27 @@ namespace OpenRA.FileFormats
|
||||
var ret = new Dictionary<string, Mod>();
|
||||
foreach (var m in mods)
|
||||
{
|
||||
if (!File.Exists("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml"))
|
||||
var yamlPath = new[] { "mods", m, "mod.yaml" }.Aggregate( Path.Combine );
|
||||
if (!File.Exists(yamlPath))
|
||||
continue;
|
||||
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromFile("mods" + Path.DirectorySeparatorChar + m + Path.DirectorySeparatorChar + "mod.yaml"));
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
|
||||
if (!yaml.NodesDict.ContainsKey("Metadata"))
|
||||
continue;
|
||||
|
||||
ret.Add(m, FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
||||
ret[m].Id = m;
|
||||
var mod = FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]);
|
||||
mod.Id = m;
|
||||
|
||||
ret.Add(m, mod);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public string[] WithPrerequisites()
|
||||
{
|
||||
return Id.Iterate(m => AllMods[m].Requires)
|
||||
.TakeWhile(m => m != null)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,16 +60,38 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ColorRamp.cs" />
|
||||
<Compile Include="Evaluator.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
<Compile Include="FieldLoader.cs" />
|
||||
<Compile Include="FileFormats\AudLoader.cs" />
|
||||
<Compile Include="FileFormats\Blast.cs" />
|
||||
<Compile Include="FileFormats\Blowfish.cs" />
|
||||
<Compile Include="FileFormats\BlowfishKeyProvider.cs" />
|
||||
<Compile Include="FileFormats\Format2.cs" />
|
||||
<Compile Include="FileFormats\Format40.cs" />
|
||||
<Compile Include="FileFormats\Format80.cs" />
|
||||
<Compile Include="FileFormats\IniFile.cs" />
|
||||
<Compile Include="Filesystem\FileSystem.cs" />
|
||||
<Compile Include="Filesystem\Folder.cs" />
|
||||
<Compile Include="Filesystem\InstallShieldPackage.cs" />
|
||||
<Compile Include="Filesystem\MixFile.cs" />
|
||||
<Compile Include="Filesystem\ZipFile.cs" />
|
||||
<Compile Include="Graphics\Dune2ShpReader.cs" />
|
||||
<Compile Include="Graphics\IGraphicsDevice.cs" />
|
||||
<Compile Include="Graphics\IInputHandler.cs" />
|
||||
<Compile Include="Graphics\PngLoader.cs" />
|
||||
<Compile Include="Graphics\ShpReader.cs" />
|
||||
<Compile Include="Graphics\ShpWriter.cs" />
|
||||
<Compile Include="Graphics\Vertex.cs" />
|
||||
<Compile Include="HttpUtil.cs" />
|
||||
<Compile Include="Graphics\VqaReader.cs" />
|
||||
<Compile Include="InstallUtils.cs" />
|
||||
<Compile Include="Manifest.cs" />
|
||||
<Compile Include="Map\PlayerReference.cs" />
|
||||
<Compile Include="Map\SmudgeReference.cs" />
|
||||
<Compile Include="Map\Terrain.cs" />
|
||||
<Compile Include="Map\TileReference.cs" />
|
||||
<Compile Include="Map\TileSet.cs" />
|
||||
<Compile Include="MiniYaml.cs" />
|
||||
<Compile Include="Mod.cs" />
|
||||
<Compile Include="PackageEntry.cs" />
|
||||
@@ -77,45 +99,22 @@
|
||||
<Compile Include="Platform.cs" />
|
||||
<Compile Include="PlayerColorRemap.cs" />
|
||||
<Compile Include="Primitives\ActionQueue.cs" />
|
||||
<Compile Include="Primitives\Bits.cs" />
|
||||
<Compile Include="Primitives\Cache.cs" />
|
||||
<Compile Include="Primitives\Cached.cs" />
|
||||
<Compile Include="Primitives\DisposableAction.cs" />
|
||||
<Compile Include="Primitives\Lazy.cs" />
|
||||
<Compile Include="Primitives\Pair.cs" />
|
||||
<Compile Include="Primitives\PriorityQueue.cs" />
|
||||
<Compile Include="Primitives\Set.cs" />
|
||||
<Compile Include="Primitives\float2.cs" />
|
||||
<Compile Include="Primitives\int2.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Thirdparty\Random.cs" />
|
||||
<Compile Include="Support\Log.cs" />
|
||||
<Compile Include="Support\Stopwatch.cs" />
|
||||
<Compile Include="Support\Timer.cs" />
|
||||
<Compile Include="Thirdparty\Random.cs" />
|
||||
<Compile Include="TypeDictionary.cs" />
|
||||
<Compile Include="Map\TileReference.cs" />
|
||||
<Compile Include="Map\Terrain.cs" />
|
||||
<Compile Include="Primitives\Cache.cs" />
|
||||
<Compile Include="Primitives\float2.cs" />
|
||||
<Compile Include="Primitives\Pair.cs" />
|
||||
<Compile Include="Map\TileSet.cs" />
|
||||
<Compile Include="Primitives\PriorityQueue.cs" />
|
||||
<Compile Include="Primitives\Lazy.cs" />
|
||||
<Compile Include="FileFormats\AudLoader.cs" />
|
||||
<Compile Include="FileFormats\Blowfish.cs" />
|
||||
<Compile Include="FileFormats\BlowfishKeyProvider.cs" />
|
||||
<Compile Include="Primitives\Set.cs" />
|
||||
<Compile Include="Graphics\Dune2ShpReader.cs" />
|
||||
<Compile Include="FileFormats\Format2.cs" />
|
||||
<Compile Include="FileFormats\Format40.cs" />
|
||||
<Compile Include="FileFormats\Format80.cs" />
|
||||
<Compile Include="FileFormats\IniFile.cs" />
|
||||
<Compile Include="Graphics\ShpReader.cs" />
|
||||
<Compile Include="Primitives\int2.cs" />
|
||||
<Compile Include="Map\SmudgeReference.cs" />
|
||||
<Compile Include="Map\PlayerReference.cs" />
|
||||
<Compile Include="Graphics\VqaReader.cs" />
|
||||
<Compile Include="Filesystem\MixFile.cs" />
|
||||
<Compile Include="Filesystem\FileSystem.cs" />
|
||||
<Compile Include="Filesystem\Folder.cs" />
|
||||
<Compile Include="Filesystem\InstallShieldPackage.cs" />
|
||||
<Compile Include="FileFormats\Blast.cs" />
|
||||
<Compile Include="Filesystem\ZipFile.cs" />
|
||||
<Compile Include="InstallUtils.cs" />
|
||||
<Compile Include="Primitives\Cached.cs" />
|
||||
<Compile Include="ColorRamp.cs" />
|
||||
<Compile Include="Primitives\Bits.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -20,21 +20,21 @@ namespace OpenRA.FileFormats
|
||||
public readonly uint Offset;
|
||||
public readonly uint Length;
|
||||
|
||||
|
||||
|
||||
public PackageEntry(uint hash, uint offset, uint length)
|
||||
{
|
||||
Hash = hash;
|
||||
Offset = offset;
|
||||
Length = length;
|
||||
}
|
||||
|
||||
|
||||
public PackageEntry(BinaryReader r)
|
||||
{
|
||||
Hash = r.ReadUInt32();
|
||||
Offset = r.ReadUInt32();
|
||||
Length = r.ReadUInt32();
|
||||
}
|
||||
|
||||
|
||||
public void Write(BinaryWriter w)
|
||||
{
|
||||
w.Write(Hash);
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.FileFormats
|
||||
MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
||||
BinaryReader reader = new BinaryReader(ms);
|
||||
|
||||
int len = name.Length >> 2;
|
||||
int len = name.Length >> 2;
|
||||
uint result = 0;
|
||||
|
||||
while (len-- != 0)
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
static Dictionary<uint, string> Names = new Dictionary<uint,string>();
|
||||
|
||||
|
||||
public static void AddStandardName(string s)
|
||||
{
|
||||
uint hash = HashFilename(s);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -23,26 +23,26 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
return Color.FromArgb((int)colors[index]);
|
||||
}
|
||||
|
||||
|
||||
public void SetColor(int index, Color color)
|
||||
{
|
||||
colors[index] = (uint)color.ToArgb();
|
||||
}
|
||||
|
||||
|
||||
public void SetColor(int index, uint color)
|
||||
{
|
||||
colors[index] = (uint)color;
|
||||
}
|
||||
|
||||
|
||||
public uint[] Values
|
||||
{
|
||||
{
|
||||
get { return colors; }
|
||||
}
|
||||
|
||||
public Palette(Stream s, bool remapTransparent)
|
||||
{
|
||||
colors = new uint[256];
|
||||
|
||||
|
||||
using (BinaryReader reader = new BinaryReader(s))
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
@@ -69,28 +69,34 @@ namespace OpenRA.FileFormats
|
||||
for(int i = 0; i < 256; i++)
|
||||
colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)p.colors[i]),i).ToArgb();
|
||||
}
|
||||
|
||||
|
||||
public Palette(Palette p)
|
||||
{
|
||||
colors = (uint[])p.colors.Clone();
|
||||
}
|
||||
|
||||
|
||||
public ColorPalette AsSystemPalette()
|
||||
{
|
||||
ColorPalette pal;
|
||||
using (var b = new Bitmap(1, 1, PixelFormat.Format8bppIndexed))
|
||||
pal = b.Palette;
|
||||
|
||||
|
||||
for (var i = 0; i < 256; i++)
|
||||
pal.Entries[i] = GetColor(i);
|
||||
|
||||
// hack around a mono bug -- the palette flags get set wrong.
|
||||
if (Platform.CurrentPlatform != PlatformType.Windows)
|
||||
typeof(ColorPalette).GetField("flags",
|
||||
typeof(ColorPalette).GetField("flags",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pal, 1);
|
||||
|
||||
|
||||
return pal;
|
||||
}
|
||||
|
||||
public static Palette Load( string filename, bool remap )
|
||||
{
|
||||
using(var s = File.OpenRead(filename))
|
||||
return new Palette(s, remap);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPaletteRemap { Color GetRemappedColor(Color original, int index); }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -21,8 +21,8 @@ namespace OpenRA
|
||||
{
|
||||
public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } }
|
||||
|
||||
static Lazy<PlatformType> currentPlatform = new Lazy<PlatformType>(GetCurrentPlatform);
|
||||
|
||||
static Lazy<PlatformType> currentPlatform = Lazy.New((Func<PlatformType>)GetCurrentPlatform);
|
||||
|
||||
static PlatformType GetCurrentPlatform()
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -21,10 +21,10 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
Dictionary<int, Color> remapColors;
|
||||
|
||||
public PlayerColorRemap(ColorRamp c, PaletteFormat fmt)
|
||||
public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
|
||||
{
|
||||
var c1 = c.GetColor(0);
|
||||
var c2 = c.GetColor(1); /* temptemp: this can be expressed better */
|
||||
var c1 = c.GetColor(0);
|
||||
var c2 = c.GetColor(1); /* temptemp: this can be expressed better */
|
||||
|
||||
var baseIndex = (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80;
|
||||
var ramp = (fmt == PaletteFormat.cnc)
|
||||
@@ -42,11 +42,11 @@ namespace OpenRA.FileFormats
|
||||
(int)(t * c2.G + (1 - t) * c1.G),
|
||||
(int)(t * c2.B + (1 - t) * c1.B));
|
||||
}
|
||||
|
||||
|
||||
public Color GetRemappedColor(Color original, int index)
|
||||
{
|
||||
Color c;
|
||||
return remapColors.TryGetValue(index, out c)
|
||||
return remapColors.TryGetValue(index, out c)
|
||||
? c : original;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", BitAllocator<T>.GetStrings(Value).ToArray());
|
||||
return BitAllocator<T>.GetStrings(Value).JoinWith(",");
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return Value.GetHashCode(); }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
public T Force() { return Value; }
|
||||
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
hasValue = false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -71,10 +71,10 @@ namespace OpenRA.FileFormats
|
||||
public static IEqualityComparer<Pair<T, U>> EqualityComparer { get { return new PairEqualityComparer(); } }
|
||||
}
|
||||
|
||||
public static class Pair
|
||||
{
|
||||
public static class Pair
|
||||
{
|
||||
public static Pair<T, U> New<T, U>(T t, U u) { return new Pair<T, U>(t, u); }
|
||||
|
||||
|
||||
static Pair()
|
||||
{
|
||||
Pair<char,Color>.uc = new ColorEqualityComparer();
|
||||
@@ -86,5 +86,5 @@ namespace OpenRA.FileFormats
|
||||
public bool Equals(Color x, Color y) { return x.ToArgb() == y.ToArgb(); }
|
||||
public int GetHashCode(Color obj) { return obj.GetHashCode(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -62,23 +62,23 @@ namespace OpenRA
|
||||
Constrain(Y, min.Y, max.Y));
|
||||
}
|
||||
|
||||
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
|
||||
public static float2 operator *(float2 b, float a) { return new float2(a * b.X, a * b.Y); }
|
||||
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
|
||||
public static float2 operator *(float2 b, float a) { return new float2(a * b.X, a * b.Y); }
|
||||
public static float2 operator *( float2 a, float2 b ) { return new float2( a.X * b.X, a.Y * b.Y ); }
|
||||
public static float2 operator /( float2 a, float2 b ) { return new float2( a.X / b.X, a.Y / b.Y ); }
|
||||
|
||||
public static bool operator ==(float2 me, float2 other) { return (me.X == other.X && me.Y == other.Y); }
|
||||
public static bool operator !=(float2 me, float2 other) { return !(me == other); }
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
public static bool operator ==(float2 me, float2 other) { return (me.X == other.X && me.Y == other.Y); }
|
||||
public static bool operator !=(float2 me, float2 other) { return !(me == other); }
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
float2 o = (float2)obj;
|
||||
return o == this;
|
||||
}
|
||||
float2 o = (float2)obj;
|
||||
return o == this;
|
||||
}
|
||||
|
||||
public static readonly float2 Zero = new float2(0, 0);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -52,11 +52,11 @@ namespace OpenRA
|
||||
|
||||
public static readonly int2 Zero = new int2(0, 0);
|
||||
public Point ToPoint() { return new Point(X, Y); }
|
||||
public PointF ToPointF() { return new PointF(X, Y); }
|
||||
public PointF ToPointF() { return new PointF(X, Y); }
|
||||
public float2 ToFloat2() { return new float2(X, Y); }
|
||||
|
||||
public override string ToString() { return string.Format("{0},{1}", X, Y); }
|
||||
|
||||
|
||||
// Change endianness of a uint32
|
||||
public static uint Swap(uint orig)
|
||||
{
|
||||
@@ -72,13 +72,13 @@ namespace OpenRA
|
||||
{
|
||||
return a + ( b - a ) * mul / div;
|
||||
}
|
||||
|
||||
|
||||
public int2 Clamp(Rectangle r)
|
||||
{
|
||||
return new int2(Math.Min(r.Right, Math.Max(X, r.Left)),
|
||||
Math.Min(r.Bottom, Math.Max(Y, r.Top)));
|
||||
Math.Min(r.Bottom, Math.Max(Y, r.Top)));
|
||||
}
|
||||
|
||||
|
||||
public static int Dot(int2 a, int2 b) { return a.X * b.X + a.Y * b.Y; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -33,39 +33,39 @@ namespace OpenRA
|
||||
get { return LogPathPrefix; }
|
||||
set
|
||||
{
|
||||
LogPathPrefix = value;
|
||||
LogPathPrefix = value;
|
||||
Directory.CreateDirectory(LogPathPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<string> FilenamesForChannel(string channelName, string baseFilename)
|
||||
{
|
||||
for(var i = 0;; i++ )
|
||||
yield return Path.Combine(LogPathPrefix,
|
||||
i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename);
|
||||
}
|
||||
static IEnumerable<string> FilenamesForChannel(string channelName, string baseFilename)
|
||||
{
|
||||
for(var i = 0;; i++ )
|
||||
yield return Path.Combine(LogPathPrefix,
|
||||
i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename);
|
||||
}
|
||||
|
||||
public static void AddChannel(string channelName, string baseFilename)
|
||||
{
|
||||
if (channels.ContainsKey(channelName)) return;
|
||||
public static void AddChannel(string channelName, string baseFilename)
|
||||
{
|
||||
if (channels.ContainsKey(channelName)) return;
|
||||
|
||||
foreach (var filename in FilenamesForChannel(channelName, baseFilename))
|
||||
try
|
||||
{
|
||||
var writer = File.CreateText(filename);
|
||||
writer.AutoFlush = true;
|
||||
foreach (var filename in FilenamesForChannel(channelName, baseFilename))
|
||||
try
|
||||
{
|
||||
var writer = File.CreateText(filename);
|
||||
writer.AutoFlush = true;
|
||||
|
||||
channels.Add(channelName,
|
||||
new ChannelInfo()
|
||||
{
|
||||
Filename = filename,
|
||||
Writer = writer
|
||||
});
|
||||
channels.Add(channelName,
|
||||
new ChannelInfo()
|
||||
{
|
||||
Filename = filename,
|
||||
Writer = writer
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
catch (IOException) { }
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (IOException) { }
|
||||
}
|
||||
|
||||
public static void Write(string channel, string format, params object[] args)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
6
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
6
OpenRA.FileFormats/Thirdparty/Random.cs
vendored
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -18,11 +18,11 @@ namespace OpenRA.Thirdparty
|
||||
{
|
||||
uint[] mt = new uint[624];
|
||||
int index = 0;
|
||||
|
||||
|
||||
public int Last;
|
||||
|
||||
public Random() : this(Environment.TickCount) { }
|
||||
|
||||
|
||||
public Random(int seed)
|
||||
{
|
||||
mt[0] = (uint)seed;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -64,13 +64,18 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public T GetOrDefault<T>()
|
||||
{
|
||||
if( dataMultiple.ContainsKey( typeof( T ) ) )
|
||||
throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", typeof( T ) ) );
|
||||
return (T)GetOrDefault(typeof(T));
|
||||
}
|
||||
|
||||
public object GetOrDefault(Type t)
|
||||
{
|
||||
if( dataMultiple.ContainsKey(t) )
|
||||
throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", t ) );
|
||||
|
||||
object ret;
|
||||
if( !dataSingular.TryGetValue( typeof( T ), out ret ) )
|
||||
return default( T );
|
||||
return (T)ret;
|
||||
if( !dataSingular.TryGetValue(t, out ret ) )
|
||||
return null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IEnumerable<T> WithInterface<T>()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -14,7 +14,6 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -34,7 +33,7 @@ namespace OpenRA
|
||||
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
||||
|
||||
public int2 Location { get { return occupySpace.Value.TopLeft; } }
|
||||
|
||||
|
||||
public int2 CenterLocation
|
||||
{
|
||||
get
|
||||
@@ -44,7 +43,7 @@ namespace OpenRA
|
||||
return HasLocation.PxPosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Sync]
|
||||
public Player Owner;
|
||||
|
||||
@@ -71,7 +70,7 @@ namespace OpenRA
|
||||
foreach (var trait in Info.TraitsInConstructOrder())
|
||||
AddTrait(trait.Create(init));
|
||||
}
|
||||
|
||||
|
||||
Move = Lazy.New( () => TraitOrDefault<IMove>() );
|
||||
|
||||
Size = Lazy.New(() =>
|
||||
@@ -83,12 +82,12 @@ namespace OpenRA
|
||||
// auto size from render
|
||||
var firstSprite = TraitsImplementing<IRender>().SelectMany(ApplyIRender).FirstOrDefault();
|
||||
if (firstSprite.Sprite == null) return int2.Zero;
|
||||
return (firstSprite.Sprite.size * firstSprite.Scale).ToInt2();
|
||||
return (firstSprite.Sprite.size * firstSprite.Scale).ToInt2();
|
||||
});
|
||||
|
||||
ApplyIRender = x => x.Render(this);
|
||||
ApplyRenderModifier = (m, p) => p.ModifyRender(this, m);
|
||||
|
||||
|
||||
Bounds = Cached.New( () => CalculateBounds(false) );
|
||||
ExtendedBounds = Cached.New( () => CalculateBounds(true) );
|
||||
}
|
||||
@@ -97,7 +96,7 @@ namespace OpenRA
|
||||
{
|
||||
Bounds.Invalidate();
|
||||
ExtendedBounds.Invalidate();
|
||||
|
||||
|
||||
currentActivity = Util.RunActivity( this, currentActivity );
|
||||
}
|
||||
|
||||
@@ -106,7 +105,7 @@ namespace OpenRA
|
||||
get { return currentActivity == null; }
|
||||
}
|
||||
|
||||
OpenRA.FileFormats.Lazy<int2> Size;
|
||||
OpenRA.FileFormats.Lazy<int2> Size;
|
||||
|
||||
// note: these delegates are cached to avoid massive allocation.
|
||||
Func<IRender, IEnumerable<Renderable>> ApplyIRender;
|
||||
@@ -117,7 +116,7 @@ namespace OpenRA
|
||||
var sprites = TraitsImplementing<IRender>().SelectMany(ApplyIRender);
|
||||
return mods.Aggregate(sprites, ApplyRenderModifier);
|
||||
}
|
||||
|
||||
|
||||
// When useAltitude = true, the bounding box is extended
|
||||
// vertically to altitude = 0 to support FindUnitsInCircle queries
|
||||
// When false, the bounding box is given for the actor
|
||||
@@ -126,7 +125,7 @@ namespace OpenRA
|
||||
{
|
||||
var size = Size.Value;
|
||||
var loc = CenterLocation - size / 2;
|
||||
|
||||
|
||||
var si = Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
if (si != null && si.Bounds != null && si.Bounds.Length > 2)
|
||||
{
|
||||
@@ -141,7 +140,7 @@ namespace OpenRA
|
||||
if (useAltitude)
|
||||
size = new int2(size.X, size.Y + move.Altitude);
|
||||
}
|
||||
|
||||
|
||||
return new Rectangle(loc.X, loc.Y, size.X, size.Y);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA
|
||||
public U Get<T,U>() where T : IActorInit<U> { return dict.Get<T>().Value( world ); }
|
||||
public bool Contains<T>() where T : IActorInit { return dict.Contains<T>(); }
|
||||
}
|
||||
|
||||
|
||||
public interface IActorInit {}
|
||||
|
||||
public interface IActorInit<T> : IActorInit
|
||||
|
||||
@@ -1,32 +1,21 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public enum SubCell
|
||||
{
|
||||
FullCell,
|
||||
TopLeft,
|
||||
TopRight,
|
||||
Center,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
}
|
||||
|
||||
public enum SubCell { FullCell, TopLeft, TopRight, Center, BottomLeft, BottomRight }
|
||||
|
||||
public class ActorMap
|
||||
{
|
||||
class InfluenceNode
|
||||
@@ -35,7 +24,7 @@ namespace OpenRA
|
||||
public SubCell subCell;
|
||||
public Actor actor;
|
||||
}
|
||||
|
||||
|
||||
InfluenceNode[,] influence;
|
||||
Map map;
|
||||
|
||||
@@ -56,7 +45,7 @@ namespace OpenRA
|
||||
if (!i.actor.Destroyed)
|
||||
yield return i.actor;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Actor> GetUnitsAt( int2 a, SubCell sub )
|
||||
{
|
||||
if (!map.IsInMap(a)) yield break;
|
||||
@@ -65,12 +54,12 @@ namespace OpenRA
|
||||
if (!i.actor.Destroyed && (i.subCell == sub || i.subCell == SubCell.FullCell))
|
||||
yield return i.actor;
|
||||
}
|
||||
|
||||
|
||||
public bool HasFreeSubCell(int2 a)
|
||||
{
|
||||
if (!AnyUnitsAt(a))
|
||||
return true;
|
||||
|
||||
|
||||
return new[]{ SubCell.TopLeft, SubCell.TopRight, SubCell.Center,
|
||||
SubCell.BottomLeft, SubCell.BottomRight }.Any(b => !AnyUnitsAt(a,b));
|
||||
}
|
||||
@@ -79,9 +68,9 @@ namespace OpenRA
|
||||
{
|
||||
return influence[ a.X, a.Y ] != null;
|
||||
}
|
||||
|
||||
|
||||
public bool AnyUnitsAt(int2 a, SubCell sub)
|
||||
{
|
||||
{
|
||||
for( var i = influence[ a.X, a.Y ] ; i != null ; i = i.next )
|
||||
if (i.subCell == sub || i.subCell == SubCell.FullCell)
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -15,8 +15,8 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public class ActorReference : IEnumerable
|
||||
{
|
||||
public readonly string Type;
|
||||
public readonly TypeDictionary InitDict;
|
||||
public string Type;
|
||||
public TypeDictionary InitDict;
|
||||
|
||||
public ActorReference( string type ) : this( type, new Dictionary<string, MiniYaml>() ) { }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -18,33 +18,33 @@ namespace OpenRA
|
||||
{
|
||||
WebClient wc;
|
||||
bool cancelled;
|
||||
|
||||
|
||||
public Download(string url, string path, Action<DownloadProgressChangedEventArgs> onProgress, Action<AsyncCompletedEventArgs, bool> onComplete)
|
||||
{
|
||||
wc = new WebClient();
|
||||
wc.Proxy = null;
|
||||
|
||||
|
||||
wc.DownloadProgressChanged += (_,a) => onProgress(a);
|
||||
wc.DownloadFileCompleted += (_,a) => onComplete(a, cancelled);
|
||||
|
||||
|
||||
Game.OnQuit += () => Cancel();
|
||||
wc.DownloadFileCompleted += (_,a) => {Game.OnQuit -= () => Cancel();};
|
||||
|
||||
wc.DownloadFileAsync(new Uri(url), path);
|
||||
|
||||
wc.DownloadFileAsync(new Uri(url), path);
|
||||
}
|
||||
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Game.OnQuit -= () => Cancel();
|
||||
wc.CancelAsync();
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
|
||||
public static string FormatErrorMessage(Exception e)
|
||||
{
|
||||
var ex = e as System.Net.WebException;
|
||||
if (ex == null) return e.Message;
|
||||
|
||||
|
||||
switch(ex.Status)
|
||||
{
|
||||
case WebExceptionStatus.NameResolutionFailure:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Effects
|
||||
{
|
||||
if (!target.IsInWorld)
|
||||
yield break;
|
||||
|
||||
|
||||
if (remainingTicks % 2 == 0)
|
||||
foreach (var r in target.Render())
|
||||
yield return r.WithPalette("highlight");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user