• R/O
  • SSH
  • HTTPS

freetrain: Commit


Commit MetaInfo

Revision105 (tree)
Zeit2013-10-20 01:38:40
Autorc477

Log Message

refactoring about resource file management.
画像などのリソースファイル読み込みの整理など

Ändern Zusammenfassung

Diff

--- NeoFT/core/contributions/game/CtbImageImportTerrainGenerator.cs (revision 104)
+++ NeoFT/core/contributions/game/CtbImageImportTerrainGenerator.cs (revision 105)
@@ -12,7 +12,6 @@
1212 using System.Drawing.Imaging;
1313 using System.Runtime.InteropServices;
1414 using System.Diagnostics;
15-using nft.framework.util;
1615 using nft.framework.plugin;
1716
1817 namespace nft.contributions.game {
@@ -36,7 +35,7 @@
3635 float hr = param[KEY_HORZ_SCALING, 1.0f];
3736 ColorChannel cc = (ColorChannel)Enum.Parse(typeof(ColorChannel), param[KEY_COLOR_CHANNEL]);
3837 int sea = param[KEY_SEA_LEVEL_HEIGHT, 0];
39- ImageRef iref = LocalFileImageRef.FromFile(src);
38+ ImageRef iref = ImageRef.FromFile(src);
4039 return new BitmapSourceTerrainMap(iref, hr, vr, cc, sea);
4140 }
4241 #endregion
--- NeoFT/framework/debug/TestViewDrawer.cs (revision 104)
+++ NeoFT/framework/debug/TestViewDrawer.cs (revision 105)
@@ -3,7 +3,6 @@
33 using System.Text;
44 using nft.ui.mainframe;
55 using nft.framework.drawing;
6-using nft.framework.util;
76 using nft.framework;
87 using System.Drawing;
98 using System.IO;
@@ -18,7 +17,7 @@
1817 private ISurfaceOld surface;
1918
2019 public TestViewDrawer() {
21- imgRef = LocalFileImageRef.FromFile(ImagePath);
20+ imgRef = ImageRef.FromFile(ImagePath);
2221 DoubleBuffered = false;
2322 surface = null;
2423 }
--- NeoFT/framework/framework/drawing/ImageRef.cs (revision 104)
+++ NeoFT/framework/framework/drawing/ImageRef.cs (revision 105)
@@ -4,12 +4,13 @@
44 using System.Drawing;
55 using System.IO;
66 using nft.framework.plugin;
7-
7+using System.Diagnostics;
8+using Encoder = System.Drawing.Imaging.Encoder;
89 namespace nft.framework.drawing {
910 /// <summary>
1011 /// Manage reference count of Image object and dispose on proper timing.
1112 /// </summary>
12- public abstract class ImageRef {
13+ public class ImageRef {
1314 /// <summary>
1415 /// Used as TranspalentColor to indicate that this image has no color to be transpalent.
1516 /// </summary>
@@ -19,20 +20,28 @@
1920 private short refcount;
2021 private object imgref = null;
2122 private Color transpalent = Color.Magenta;
23+ protected IFileSource source;
2224
23- protected ImageRef()
24- : this(Lifetime.Long) {
25+ protected ImageRef(IFileSource src)
26+ : this(src, Lifetime.Long) {
2527 }
2628
27- protected ImageRef(Lifetime lifetime) {
29+ protected ImageRef(IFileSource src, Lifetime lifetime) {
30+ this.source = src;
2831 this.life = lifetime;
2932 this.refcount = 0;
3033 }
3134
35+ public IFileSource FileSource {
36+ get {
37+ return source;
38+ }
39+ }
40+
3241 /// <summary>
3342 /// Do not call while reference count is not zero.
3443 /// </summary>
35- protected void ForceDispose(){
44+ protected virtual void ForceDispose(){
3645 if (refcount > 0)
3746 throw new InvalidOperationException("Reference count is not zero.");
3847 if (imgref != null) {
@@ -48,7 +57,7 @@
4857 }
4958 }
5059
51- protected Image PrepareImage() {
60+ protected virtual Image PrepareImage() {
5261 Image ret;
5362 if (imgref != null) {
5463 if (imgref is WeakReference) {
@@ -99,6 +108,20 @@
99108 }
100109 }
101110
111+ protected virtual Image CreateImage() {
112+ //return Image.FromFile(((LocalFile)source).AbsolutePath);
113+ Stream s = source.OpenRead();
114+ Encoder enc = Encoder.Version;
115+ Image img = Bitmap.FromStream(s);
116+ s.Close();
117+ s.Dispose();
118+ return new Bitmap(img);
119+ }
120+
121+ protected virtual void DisposeImage(Image image) {
122+ image.Dispose();
123+ }
124+
102125 /// <summary>
103126 /// Decrease reference count.
104127 /// Do not Dispose the image which returned by AddRef method.
@@ -134,11 +157,56 @@
134157 set { this.life = value; }
135158 }
136159
137- protected virtual void DisposeImage(Image image) {
138- image.Dispose();
160+ public override bool Equals(object obj) {
161+ ImageRef iref = obj as ImageRef;
162+ if (iref != null) {
163+ return source.Equals(iref.source);
164+ } else {
165+ return false;
166+ }
139167 }
140168
141- protected abstract Image CreateImage();
169+ public override int GetHashCode() {
170+ return source.GetHashCode();
171+ }
172+
173+ #region local non bundled image treatment.
174+ static private readonly Dictionary<String, ImageRef> pathlist = new Dictionary<String, ImageRef>();
175+
176+ /// <summary>
177+ /// Get or create ImageRef object for an image specifed by the file path
178+ /// Caller do not need to call first 'IncreaseRefCount'
179+ /// </summary>
180+ /// <param name="filename"></param>
181+ /// <returns></returns>
182+ public static ImageRef FromFile(string filename) {
183+ string path = Path.GetFullPath(filename);
184+ ImageRef refObj = null;
185+ if (!pathlist.TryGetValue(path, out refObj)) {
186+ FileInfo info = new FileInfo(path);
187+ if (info.Exists) {
188+ IFileSource src = new LocalFile(info.FullName);
189+ refObj = new ImageRef(src);
190+ pathlist.Add(path, refObj);
191+ }
192+ }
193+ return refObj;
194+ }
195+
196+ public static void FreeIsolatedImages() {
197+ List<string> work = new List<string>();
198+ foreach (string key in pathlist.Keys) {
199+ ImageRef ir = pathlist[key];
200+ if (ir.RefCount == 0) {
201+ ir.ForceDispose();
202+ work.Add(key);
203+ }
204+ }
205+ foreach (string key in work) {
206+ pathlist.Remove(key);
207+ }
208+ }
209+ #endregion
142210 }
143211
144212 }
--- NeoFT/framework/framework/plugin/PluginImageManager.cs (revision 104)
+++ NeoFT/framework/framework/plugin/PluginImageManager.cs (revision 105)
@@ -6,12 +6,11 @@
66 using System.Runtime.Serialization;
77 using System.Drawing;
88 using System.Diagnostics;
9-using nft.framework.util;
109
1110 namespace nft.framework.plugin {
1211 class PluginImageManager {
13- static private readonly Dictionary<String, ContributionImageRef> pathlist
14- = new Dictionary<String, ContributionImageRef>();
12+ static private readonly Dictionary<String, ImageEntry> pathlist
13+ = new Dictionary<String, ImageEntry>();
1514
1615 /// <summary>
1716 /// load image from the plugin directory.
@@ -21,12 +20,12 @@
2120 /// <returns></returns>
2221 public static ImageRef GetBundledImageRef(Contribution ctb, string relativePath) {
2322 string key = MakePluginPath(ctb, relativePath);
24- ContributionImageRef ir;
23+ ImageEntry ir;
2524 if (!pathlist.TryGetValue(key, out ir)) {
26- ir = new ContributionImageRef(ctb, relativePath, false);
25+ ir = new ImageEntry(ctb, relativePath, false);
2726 pathlist.Add(key, ir);
2827 }
29- return ir;
28+ return ImageRef.FromFile(ir.FullPath);
3029 }
3130
3231 /// <summary>
@@ -38,27 +37,14 @@
3837 /// <returns></returns>
3938 public static ImageRef GetCachedImageRef(Contribution ctb, string relativePath) {
4039 string key = MakeCtbCachePath(ctb, relativePath);
41- ContributionImageRef ir;
40+ ImageEntry ir;
4241 if (!pathlist.TryGetValue(key, out ir)) {
43- ir = new ContributionImageRef(ctb, relativePath, true);
42+ ir = new ImageEntry(ctb, relativePath, true);
4443 pathlist.Add(key, ir);
4544 }
46- return ir;
45+ return ImageRef.FromFile(ir.FullPath);
4746 }
4847
49- public static void FreeIsolatedImages() {
50- List<string> work = new List<string>();
51- foreach (string key in pathlist.Keys) {
52- ContributionImageRef ir = pathlist[key];
53- if (ir.FreeIsIsolated()) {
54- work.Add(key);
55- }
56- }
57- foreach (string key in work) {
58- pathlist.Remove(key);
59- }
60- }
61-
6248 protected internal static string MakePluginPath(Contribution ctb, string relative) {
6349 return Path.Combine(ctb.PluginDir, relative);
6450 }
@@ -68,7 +54,7 @@
6854 }
6955 }
7056
71- class ContributionImageRef : FileImageRef, ISerializable {
57+ class ImageEntry : ISerializable {
7258 protected readonly string cid;
7359 protected readonly string relPath;
7460 protected readonly string parentDir;
@@ -81,13 +67,13 @@
8167 }
8268 }
8369
84- internal ContributionImageRef(Contribution ctb, string relativepath, bool cached) {
70+ internal ImageEntry(Contribution ctb, string relativepath, bool cached) {
8571 this.cid = ctb.ID;
8672 this.relPath = relativepath;
8773 this.parentDir = ResolveParentDir(ctb, cached);
8874 }
8975
90- private ContributionImageRef(SerializationInfo info, StreamingContext context) {
76+ private ImageEntry(SerializationInfo info, StreamingContext context) {
9177 this.cid = info.GetString("cid");
9278 this.relPath = info.GetString("path");
9379 Contribution ctb = PluginManager.theInstance.GetContribution(cid);
@@ -95,18 +81,10 @@
9581 this.parentDir = ResolveParentDir(ctb, cached);
9682 }
9783
98- public override string FullPath {
84+ internal protected string FullPath {
9985 get { return Path.Combine(parentDir, relPath); }
10086 }
10187
102- internal bool FreeIsIsolated() {
103- bool b = (RefCount > 0);
104- if (!b) {
105- base.ForceDispose();
106- }
107- return b;
108- }
109-
11088 #region ISerializable メンバ
11189
11290 public void GetObjectData(SerializationInfo info, StreamingContext context) {
@@ -119,5 +97,6 @@
11997 }
12098
12199 #endregion
100+
122101 }
123102 }
--- NeoFT/framework/framework/FileSource.cs (nonexistent)
+++ NeoFT/framework/framework/FileSource.cs (revision 105)
@@ -0,0 +1,119 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using System.IO;
5+
6+using AccessSpeed = nft.framework.FileAccessSpeed;
7+
8+namespace nft.framework
9+{
10+ public enum FileAccessSpeed
11+ {
12+ Fast, // Ordinaly local file (stored as is).
13+ Slow, // Compressed local file (ZIP), , or Stored in a bit slow device.
14+ VerySlow // Network remote file, or sometimes failed to open and require reload.
15+ }
16+
17+ public interface IFileSource
18+ {
19+ /// <summary>
20+ /// Open File as Stream
21+ /// </summary>
22+ /// <returns></returns>
23+ Stream OpenRead();
24+
25+ AccessSpeed AccessSpeed { get; }
26+
27+ /// <summary>
28+ /// File offset path. Must be identical and consist of
29+ /// characters available for offset path, in oredr to create cache.
30+ /// </summary>
31+ string IdenticalPath { get; }
32+
33+ /// <summary>
34+ /// Reffered when cache is latest or not. Negative value will force update cache.
35+ /// </summary>
36+ long Timestamp { get; }
37+ }
38+
39+ public abstract class FileSource : IFileSource
40+ {
41+ public abstract string IdenticalPath { get; }
42+
43+ public abstract Stream OpenRead();
44+
45+ public override bool Equals(object obj) {
46+ IFileSource iref = obj as IFileSource;
47+ if (iref != null) {
48+ return IdenticalPath.Equals(iref.IdenticalPath);
49+ } else {
50+ return false;
51+ }
52+ }
53+
54+ public override int GetHashCode() {
55+ return IdenticalPath.GetHashCode();
56+ }
57+
58+ [Obsolete("non blocking method is desired.")]
59+ public virtual void CopyToLocal(string path) {
60+ using (Stream s_in = OpenRead()) {
61+ using (FileStream s_out = new FileStream(path, FileMode.Create, FileAccess.Write)) {
62+ int size = 4096;
63+ byte[] buffer = new byte[size];
64+ int numBytes;
65+ while ((numBytes = s_in.Read(buffer, 0, size)) > 0) {
66+ s_out.Write(buffer, 0, numBytes);
67+ }
68+ }
69+ }
70+ }
71+
72+ public abstract AccessSpeed AccessSpeed { get; }
73+
74+ public abstract long Timestamp { get; }
75+ }
76+
77+ public class LocalFile : FileSource, IFileSource
78+ {
79+ protected string idpath;
80+ protected string fullpath;
81+ public LocalFile(string path) {
82+ this.fullpath = Path.GetFullPath(path);
83+ this.idpath = this.fullpath.Replace(":\\", "$\\");
84+ }
85+
86+ public LocalFile(string parent_path, string offset_path) {
87+ Char c = offset_path[0];
88+ if (c == '/' || c == '\\') {
89+ this.idpath = offset_path.Substring(1);
90+ } else {
91+ this.idpath = offset_path;
92+ }
93+ this.fullpath = Path.Combine(parent_path, this.idpath);
94+ }
95+
96+ public override Stream OpenRead() {
97+ return new FileStream(fullpath, FileMode.Open, FileAccess.Read);
98+ }
99+
100+ public override AccessSpeed AccessSpeed {
101+ get { return AccessSpeed.Fast; }
102+ }
103+
104+ public override string IdenticalPath {
105+ get { return idpath; }
106+ }
107+
108+ public string AbsolutePath {
109+ get { return fullpath; }
110+ }
111+
112+ public override long Timestamp {
113+ get {
114+ FileInfo info =new FileInfo(AbsolutePath);
115+ return info.LastAccessTime.Ticks;
116+ }
117+ }
118+ }
119+}
--- NeoFT/framework/framework/loader/XmlParamParser.cs (revision 104)
+++ NeoFT/framework/framework/loader/XmlParamParser.cs (revision 105)
@@ -25,7 +25,7 @@
2525
2626 public IEnumerator<KeyValuePair<String, IParamsParser>> EnumChildren() {
2727 foreach (XmlAttribute a in node.Attributes) {
28- yield return new KeyValuePair<String,IParamsParser>(a.Name, new PlainStringParam(a.Value));
28+ yield return new KeyValuePair<String,IParamsParser>(a.Name, new PlainStringParam(a.Value, this));
2929 }
3030 foreach (XmlNode n in node.ChildNodes) {
3131 yield return new KeyValuePair<String, IParamsParser>(n.Name, new XmlParamParser(n));
@@ -36,7 +36,7 @@
3636 if (node.Attributes != null) {
3737 XmlAttribute a = node.Attributes[key];
3838 if (a != null) {
39- yield return new PlainStringParam(a.Value);
39+ yield return new PlainStringParam(a.Value, this);
4040 }
4141 }
4242 foreach (XmlNode n in node.SelectNodes(key)) {
@@ -43,6 +43,15 @@
4343 yield return new XmlParamParser(n);
4444 }
4545 }
46+
47+ public IFileSource GetFileSource(string path) {
48+ Uri uri= XmlUtil.resolve(node, path);
49+ if (uri.IsFile) {
50+ return new LocalFile(uri.LocalPath);
51+ } else {
52+ return null;
53+ }
54+ }
4655 }
4756
4857 }
--- NeoFT/framework/framework/loader/IParamsParser.cs (revision 104)
+++ NeoFT/framework/framework/loader/IParamsParser.cs (revision 105)
@@ -17,9 +17,26 @@
1717 /// </summary>
1818 bool IsNull { get; }
1919
20+ /// <summary>
21+ /// Enumelate all children with it's key.
22+ /// </summary>
23+ /// <returns></returns>
2024 IEnumerator<KeyValuePair<String,IParamsParser>> EnumChildren();
2125
26+ /// <summary>
27+ /// Enumelate all children which corresnpond to specified key.
28+ /// </summary>
29+ /// <param name="key"></param>
30+ /// <returns></returns>
2231 IEnumerator<IParamsParser> EnumChildren(string key);
32+
33+ /// <summary>
34+ /// Resolve offset file path and returns as IFileSource.
35+ /// returns null if corresponding file does not found.
36+ /// </summary>
37+ /// <param name="path"></param>
38+ /// <returns></returns>
39+ IFileSource GetFileSource(string path);
2340 }
2441
2542 public sealed class NullParam : IParamsParser {
@@ -42,15 +59,24 @@
4259 public IEnumerator<IParamsParser> EnumChildren(string key) {
4360 yield break;
4461 }
62+
63+ public IFileSource GetFileSource(string path) {
64+ return null;
65+ }
4566 }
4667
4768 public class PlainStringParam : IParamsParser
4869 {
4970 private readonly string text;
50- public PlainStringParam(string s) {
71+ private readonly IParamsParser owner;
72+ public PlainStringParam(string s, IParamsParser owner) {
5173 this.text = s;
74+ this.owner = owner;
5275 }
5376
77+ public PlainStringParam(string s) :this(s, null){
78+ }
79+
5480 public string InnerText {
5581 get { return text; }
5682 }
@@ -66,5 +92,13 @@
6692 public IEnumerator<IParamsParser> EnumChildren(string key) {
6793 yield break;
6894 }
95+
96+ public IFileSource GetFileSource(string path) {
97+ if (owner != null) {
98+ return owner.GetFileSource(path);
99+ } else {
100+ return null;
101+ }
102+ }
69103 }
70104 }
--- NeoFT/framework/framework/ParamsReader.cs (revision 104)
+++ NeoFT/framework/framework/ParamsReader.cs (revision 105)
@@ -37,6 +37,15 @@
3737 }
3838 }
3939
40+ public IFileSource GetFileSource(string path) {
41+ IFileSource src = null;
42+ foreach (IParamsParser pp in loader) {
43+ src = pp.GetFileSource(path);
44+ if (src != null) break;
45+ }
46+ return src;
47+ }
48+
4049 public ParamsReader this[int index] {
4150 get {
4251 if (index < 0 || index >= loader.Length) {
--- NeoFT/framework/util/FileImageRef.cs (revision 104)
+++ NeoFT/framework/util/FileImageRef.cs (nonexistent)
@@ -1,27 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Text;
4-using nft.framework.drawing;
5-using System.IO;
6-using System.Drawing;
7-using System.Runtime.Serialization;
8-
9-namespace nft.framework.util {
10- public abstract class FileImageRef : ImageRef {
11-
12- public abstract string FullPath { get; }
13-
14- protected override Image CreateImage() {
15- return Image.FromFile(FullPath);
16- }
17-
18- public override bool Equals(object obj) {
19- FileImageRef iref = obj as FileImageRef;
20- return FullPath.Equals(iref.FullPath);
21- }
22-
23- public override int GetHashCode() {
24- return FullPath.GetHashCode();
25- }
26- }
27-}
--- NeoFT/framework/util/LocalFileImageRef.cs (revision 104)
+++ NeoFT/framework/util/LocalFileImageRef.cs (nonexistent)
@@ -1,52 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Text;
4-using nft.framework.drawing;
5-using System.IO;
6-using System.Drawing;
7-using System.Runtime.Serialization;
8-
9-namespace nft.framework.util {
10- public class LocalFileImageRef : FileImageRef {
11- static private readonly Dictionary<String, LocalFileImageRef> pathlist
12- = new Dictionary<String, LocalFileImageRef>();
13-
14- public readonly string path;
15-
16- private LocalFileImageRef(string id) {
17- this.path = id;
18- }
19-
20- public override string FullPath { get { return path; } }
21-
22- /// <summary>
23- /// Get or create ImageRef object for an image specifed by the file path
24- /// Caller do not need to call first 'IncreaseRefCount'
25- /// </summary>
26- /// <param name="filename"></param>
27- /// <returns></returns>
28- public static ImageRef FromFile(string filename) {
29- string path = Path.GetFullPath(filename);
30- LocalFileImageRef refObj = null;
31- if (!pathlist.TryGetValue(path, out refObj)) {
32- refObj = new LocalFileImageRef(path);
33- pathlist.Add(path, refObj);
34- }
35- return refObj;
36- }
37-
38- public static void FreeIsolatedImages() {
39- List<string> work = new List<string>();
40- foreach (string key in pathlist.Keys) {
41- LocalFileImageRef ir = pathlist[key];
42- if (ir.RefCount == 0) {
43- ir.ForceDispose();
44- work.Add(key);
45- }
46- }
47- foreach (string key in work) {
48- pathlist.Remove(key);
49- }
50- }
51- }
52-}
--- NeoFT/framework/util/ProgressMonitor.cs (revision 104)
+++ NeoFT/framework/util/ProgressMonitor.cs (revision 105)
@@ -45,7 +45,7 @@
4545 Detach(attached);
4646 attached = source;
4747 this.attachLevel = attachLevel -1;
48- source.OnProgress += new ProgressHandler(this.AttachListener);
48+ source.OnProgress += new ProgressHandler(this.HandleOnProgress);
4949 }
5050
5151 /// <summary>
@@ -54,7 +54,7 @@
5454 /// <param name="source"></param>
5555 public void Detach( ProgressMonitor source )
5656 {
57- OnProgress -= new ProgressHandler(this.AttachListener);
57+ OnProgress -= new ProgressHandler(this.HandleOnProgress);
5858 }
5959
6060 #region lapper methods
@@ -96,7 +96,7 @@
9696 }
9797
9898 // delegate called from attached monitor
99- private void AttachListener( int level, int percentage ,string msg )
99+ internal protected void HandleOnProgress( int level, int percentage ,string msg )
100100 {
101101 if (OnProgress != null) {
102102 OnProgress(attachLevel + level, percentage, msg);
@@ -151,7 +151,7 @@
151151 {
152152 max = value;
153153 current = 0;
154- owner.OnProgress(level,0,null);
154+ owner.HandleOnProgress(level, 0, null);
155155 }
156156 }
157157
@@ -161,7 +161,7 @@
161161 set
162162 {
163163 text = value;
164- owner.OnProgress(level,percentage,text);
164+ owner.HandleOnProgress(level,percentage,text);
165165 }
166166 }
167167 #endregion
@@ -176,7 +176,7 @@
176176 text = msg;
177177 current += count;
178178 if(max<current) current = max;
179- owner.OnProgress(level,percentage,text);
179+ owner.HandleOnProgress(level, percentage, text);
180180 }
181181 }
182182 }
--- NeoFT/framework/util/XmlUtil.cs (revision 104)
+++ NeoFT/framework/util/XmlUtil.cs (revision 105)
@@ -3,6 +3,7 @@
33 using System.IO;
44 using System.Net;
55 using System.Xml;
6+using System.Diagnostics;
67
78 namespace nft.util
89 {
@@ -84,7 +85,12 @@
8485 /// </summary>
8586 public static Uri resolve( XmlNode context, string relative )
8687 {
87- return new Uri(new Uri(context.BaseURI),relative);
88+ Char c = relative[0];
89+ if(c=='/' || c=='\\'){
90+ relative = relative.Substring(1);
91+ }
92+ Uri baseuri = new Uri(context.BaseURI);
93+ return new Uri(baseuri,relative);
8894 }
8995
9096 /// <summary>
--- NeoFT/TestLauncher/test/ParamsReaderTest.cs (revision 104)
+++ NeoFT/TestLauncher/test/ParamsReaderTest.cs (revision 105)
@@ -12,7 +12,7 @@
1212 {
1313 class ParamsReaderTest
1414 {
15- static readonly string xmlPath = @"\system\plugin.xml";
15+ static readonly string xmlPath = @"system\plugin.xml";
1616 static XmlDocument doc;
1717
1818 static ParamsReaderTest() {
@@ -35,6 +35,16 @@
3535 Debug.WriteLine("command = " + r4["menupath"].InnerText);
3636 }
3737 }
38+ IFileSource fs = reader.GetFileSource("test.txt");
39+ Debug.WriteLine("file=" + (fs != null ? fs.IdenticalPath : "null"));
40+ fs = reader.GetFileSource("work/test2.txt");
41+ Debug.WriteLine("file2=" + (fs != null ? fs.IdenticalPath : "null"));
42+ fs = reader.GetFileSource(@"/work/test3.txt");
43+ Debug.WriteLine("file3=" + (fs != null ? fs.IdenticalPath : "null"));
44+ fs = reader.GetFileSource(@"work\test4.txt");
45+ Debug.WriteLine("file4=" + (fs != null ? fs.IdenticalPath : "null"));
46+ fs = reader.GetFileSource(@"\work\test5.txt");
47+ Debug.WriteLine("file5=" + (fs != null ? fs.IdenticalPath : "null"));
3848 }
3949
4050 }
--- NeoFT/ui_jp/ui/system/ErrorMessageBox.cs (revision 104)
+++ NeoFT/ui_jp/ui/system/ErrorMessageBox.cs (revision 105)
@@ -112,9 +112,9 @@
112112 //
113113 // detail
114114 //
115- this.detail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
116- | System.Windows.Forms.AnchorStyles.Left)
117- | System.Windows.Forms.AnchorStyles.Right)));
115+ this.detail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
116+ | System.Windows.Forms.AnchorStyles.Left)
117+ | System.Windows.Forms.AnchorStyles.Right)));
118118 this.detail.Location = new System.Drawing.Point(16, 80);
119119 this.detail.Multiline = true;
120120 this.detail.Name = "detail";
@@ -137,8 +137,8 @@
137137 //
138138 // msg
139139 //
140- this.msg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
141- | System.Windows.Forms.AnchorStyles.Right)));
140+ this.msg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
141+ | System.Windows.Forms.AnchorStyles.Right)));
142142 this.msg.Location = new System.Drawing.Point(72, 8);
143143 this.msg.Name = "msg";
144144 this.msg.Size = new System.Drawing.Size(536, 48);
@@ -155,7 +155,7 @@
155155 this.linkLabel1.TabIndex = 4;
156156 this.linkLabel1.TabStop = true;
157157 this.linkLabel1.TargetUrl = "http://www.kohsuke.org/freetrain/wiki/pukiwiki.php?%A5%D0%A5%B0%CA%F3%B9%F0%A4%CE" +
158- "%BC%EA%BD%E7";
158+ "%BC%EA%BD%E7";
159159 this.linkLabel1.Text = " バグの報告先";
160160 this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
161161 //
@@ -171,8 +171,8 @@
171171 //
172172 // note
173173 //
174- this.note.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
175- | System.Windows.Forms.AnchorStyles.Right)));
174+ this.note.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
175+ | System.Windows.Forms.AnchorStyles.Right)));
176176 this.note.BackColor = System.Drawing.SystemColors.Highlight;
177177 this.note.ForeColor = System.Drawing.SystemColors.HighlightText;
178178 this.note.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -186,7 +186,6 @@
186186 // throwButton
187187 //
188188 this.throwButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
189- this.throwButton.DialogResult = System.Windows.Forms.DialogResult.Abort;
190189 this.throwButton.Location = new System.Drawing.Point(200, 220);
191190 this.throwButton.Name = "throwButton";
192191 this.throwButton.Size = new System.Drawing.Size(146, 23);
@@ -193,6 +192,7 @@
193192 this.throwButton.TabIndex = 7;
194193 this.throwButton.Text = "再throw(開発用)";
195194 this.throwButton.UseVisualStyleBackColor = true;
195+ this.throwButton.Click += new System.EventHandler(this.throwButton_Click);
196196 //
197197 // ErrorMessageBox
198198 //
@@ -222,5 +222,9 @@
222222 string text = detail.Text;//.Replace("\n","\r\n");
223223 Clipboard.SetDataObject(text, true);
224224 }
225+
226+ private void throwButton_Click(object sender, EventArgs e) {
227+ throw exception;
228+ }
225229 }
226230 }
--- NeoFT/ui_jp/ui/core/TerrainFromBitmapSetup.cs (revision 104)
+++ NeoFT/ui_jp/ui/core/TerrainFromBitmapSetup.cs (revision 105)
@@ -14,7 +14,6 @@
1414 using System.Collections;
1515 using System.Runtime.InteropServices;
1616 using nft.framework.drawing;
17-using nft.framework.util;
1817
1918 using Generator = nft.contributions.game.CtbImageImportTerrainGenerator;
2019 namespace nft.ui.core {
@@ -109,7 +108,7 @@
109108 ClearSelectedImage();
110109 ImageRef img = null;
111110 try {
112- img = LocalFileImageRef.FromFile(path);
111+ img = ImageRef.FromFile(path);
113112 } catch (Exception) {
114113 MessageBox.Show(
115114 this, "ファイルを画像として開けません\n" + path, "読み込み画像", MessageBoxButtons.OK
Show on old repository browser