• R/O
  • SSH
  • HTTPS

marathon: コミット


コミットメタ情報

リビジョン288 (tree)
日時2007-05-10 22:54:53
作者hogepiyo

ログメッセージ

*** empty log message ***

変更サマリ

差分

--- marathon/trunk/MapEditorOne/Reminder.txt (revision 287)
+++ marathon/trunk/MapEditorOne/Reminder.txt (revision 288)
@@ -14,6 +14,9 @@
1414 もうすこし整備してHPLLibに収められると良い。
1515 特に点の追加・削除・セットアップなどなどは煩雑になりそうだし、良く分からん部分が多すぎる
1616
17+
18+--------------------------------
19+--フラグが立った!
1720 ・theApp(CMapEditorOne)の持ち物チェック(イベント管理上特に重要なもの)
1821
1922 -bool isSelectingGroup;
@@ -22,7 +25,10 @@
2225 void CMapEditorSDIView::setStartPointForSelectGroup(int px, int py)
2326 でtrue。
2427
28+-POINT selectStartPoint
29+「選択開始座標」
2530
31+-----------------------------
2632 ・そうでもないけど書いちゃったもの
2733 -CStringArray LevelNameList;
2834 MapEditorSDIView_Event_mMenu.cppで登録
--- marathon/trunk/MapEditorOne/src/MapEditorSDI.cpp (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDI.cpp (revision 288)
@@ -181,7 +181,19 @@
181181
182182 //Zoom
183183 //innerSetting.getInt(mapeditorone::TagType::ZOOM_DIVISION_DEFAULT);
184- zoomDivision = ZOOM_DIVISION_DEFAULT;
184+// zoomDivision = ZOOM_DIVISION_DEFAULT;
185+// theApp.gridManager->
186+// offset.x = 0;
187+// offset.y = 0;
188+ //1WU 1/2WU 1/4WU 1/8 WU
189+ int intervals[]={
190+ WORLD_ONE * 2, WORLD_ONE, WORLD_ONE / 2, WORLD_ONE / 4, WORLD_ONE / 8
191+ };
192+ for(int i = 0; i < NUMBER_OF_GLID; i ++){
193+ gridIntervals[i] = intervals[i];
194+ }
195+
196+ //拡大関連の設定
185197 hpl::aleph::view::ZoomProperties zoomProp;
186198 zoomProp.zoomDivisionStep = innerSetting.getInt(mapeditorone::TagType::ZOOM_DIVISION_STEP);
187199 zoomProp.zoomDivisionDefault = innerSetting.getInt(mapeditorone::TagType::ZOOM_DIVISION_DEFAULT);
@@ -189,23 +201,19 @@
189201 zoomProp.zoomDivisionMax = innerSetting.getInt(mapeditorone::TagType::ZOOM_DIVISION_MAX);
190202 zoomProp.zoomDivStepThreshold = innerSetting.getInt(mapeditorone::TagType::ZOOM_DIV_STEP_THRESHOLD);
191203 zoomProp.zoomDivisionStepDetail = innerSetting.getInt(mapeditorone::TagType::ZOOM_DIVISION_STEP_DETAIL);
204+ for(int i = 0; i < NUMBER_OF_GLID; i ++){
205+ zoomProp.gridIntervals[i] = intervals[i];
206+ }
192207 this->gridManager = new hpl::aleph::view::HPLViewGridManager(&zoomProp);
208+
193209 isPressLButtonWithCtrl = false;
194210
195- offset.x = 0;
196- offset.y = 0;
197-
198211 objectPropertyDialog = NULL;
199212
200- //1WU 1/2WU 1/4WU 1/8 WU
201- int intervals[]={
202- WORLD_ONE * 2, WORLD_ONE, WORLD_ONE / 2, WORLD_ONE / 4, WORLD_ONE / 8
203- };
204- for(int i = 0; i < NUMBER_OF_GLID; i ++){
205- gridIntervals[i] = intervals[i];
206- }
213+
207214 AfxInitRichEdit();
208215
216+ //選択関係
209217 this->selectDatas.clear();
210218 isSelectingGroup = false;
211219
@@ -479,22 +487,6 @@
479487 return -1;
480488 }
481489
482-//convert view <-> world point
483-world_point2d getWorldPoint2DFromViewPoint(int viewPX, int viewPY)
484-{
485- world_point2d point;
486- point.x = (world_distance)((viewPX - theApp.offset.x) *
487- theApp.zoomDivision - OFFSET_X_WORLD);
488- point.y = (world_distance)((viewPY - theApp.offset.y) *
489- theApp.zoomDivision - OFFSET_Y_WORLD);
490- return point;
491-}
492-void getViewPointFromWorldPoint2D(world_point2d& point, int *dest)
493-{
494- dest[0] = (point.x + OFFSET_X_WORLD)/theApp.zoomDivision + theApp.offset.x;
495- dest[1] = (point.y + OFFSET_Y_WORLD)/theApp.zoomDivision + theApp.offset.y;
496-}
497-
498490 //TODO
499491 void setCursor()
500492 {
@@ -665,7 +657,7 @@
665657 continue;
666658 }
667659 if(hpl::aleph::map::isSelectPoint(world_point, point->vertex,
668- POINT_DISTANCE_EPSILON * theApp.zoomDivision))
660+ POINT_DISTANCE_EPSILON * theApp.gridManager->getZoomDivision()))
669661 {
670662 //追加しない
671663 isFound = true;
@@ -692,7 +684,7 @@
692684 endpoint_data *begin = &EndpointList[line->endpoint_indexes[0]];
693685 endpoint_data *end = &EndpointList[line->endpoint_indexes[1]];
694686 if(hpl::aleph::map::isSelectLine(world_point, begin->vertex, end->vertex,
695- LINE_DISTANCE_EPSILON * theApp.zoomDivision))
687+ LINE_DISTANCE_EPSILON * theApp.gridManager->getZoomDivision()))
696688 {
697689 isFound = true;
698690 lineIndex = i;
--- marathon/trunk/MapEditorOne/src/MapEditorOneInnerSetting.cpp (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorOneInnerSetting.cpp (revision 288)
@@ -1,4 +1,6 @@
11 #include "MapEditorOneInnerSetting.h"
2+#include "HPLLib/HPLAlephLib.h"
3+
24 #include <fstream>
35 #include <cstdio>
46 #include <cstdlib>
@@ -18,7 +20,7 @@
1820 //タグ読み取り
1921 char buf[MAX_FILE_PATH];
2022 int counter = 0;
21- while(ifs.readLine(buf, MAX_FILE_PATH) != NULL){
23+ while(ifs.getline(buf, MAX_FILE_PATH) != NULL){
2224 if(strcmp(buf, "")){
2325 continue;
2426 }
@@ -32,12 +34,16 @@
3234 MessageBox(NULL, L"Cannot open inner data file", L"", MB_OK);
3335 exit(-1);
3436 }
35- while(ifs.readLine(buf, MAX_FILE_PATH) != NULL){
37+ while(ifs.getline(buf, MAX_FILE_PATH) != NULL){
3638 std::string src(buf);
3739 std::vector<std::string> pair = hpl::string::Split(src, "=");
40+ if(pair.size() < 2){
41+ //空白は無視
42+ continue;
43+ }
3844 for(int i = 0; i < mapeditorone::TagType::MaxTagTypes; i ++){
3945 if(pair[0].compare(tagMap[i]) == 0){
40-
46+ datas[i] = pair[1];
4147 }
4248 }
4349 }
--- marathon/trunk/MapEditorOne/src/MapEditorSDI.h (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDI.h (revision 288)
@@ -72,14 +72,6 @@
7272 //
7373
7474 const int NUMBER_OF_POLYGON_TYPE = 24;
75-const int ZOOM_DIVISION_STEP = 5;
76-const int ZOOM_DIVISION_MAX = 200;
77-const int ZOOM_DIVISION_MIN = 1;
78-const int ZOOM_DIVISION_DEFAULT = 100;
79-const int OFFSET_X_WORLD = 32768;
80-const int OFFSET_Y_WORLD = 32768;
81-const int NUMBER_OF_GLID = 5;
82-
8375 const int NUMBER_OF_OBJECT_TYPES = 6;
8476 const int NUMBER_OF_ACTIVATE_TYPES = 4;
8577 const int NUMBER_OF_MAP_OBJECT_TYPES = 6;
@@ -197,15 +189,15 @@
197189 int editLevelIndex;
198190
199191
192+public:
200193 ///////////////////////////
201194 //グリッド・表示関係
202195
203-public:
204196 /**拡大縮小・スクロール管理マネージャー*/
205197 hpl::aleph::view::HPLViewGridManager* viewGrid;
206198
207199 /**選択中の倍率*/
208- int zoomDivision;
200+ //int zoomDivision;
209201
210202 //
211203 hpl::aleph::view::HPLViewGridManager* gridManager;
@@ -214,13 +206,13 @@
214206 int gridIntervals[NUMBER_OF_GLID];
215207
216208 //位置オフセット
217- POINT offset;
209+ //POINT offset;
218210
219211 /**現在のマウス座標*/
220- POINT nowMousePoint;
212+ //POINT nowMousePoint;
221213
222214 /**一つ前のマウス座標*/
223- POINT oldMousePoint;
215+ //POINT oldMousePoint;
224216
225217 //ポリゴンタイプの色
226218 COLORREF polygonTypeColor[NUMBER_OF_POLYGON_TYPE];
@@ -403,10 +395,6 @@
403395 int searchSelectLine(int viewPX, int viewPY);
404396 int searchSelectPolygon(int viewPX, int viewPY);
405397
406-//convert view <-> world point
407-world_point2d getWorldPoint2DFromViewPoint(int viewPX, int viewPY);
408-void getViewPointFromWorldPoint2D(world_point2d& point, int *dest);
409-
410398 void setCursor();
411399 /**
412400 change is this
@@ -451,3 +439,7 @@
451439
452440 //CString GetModulePathFileName(CString pName);
453441
442+//簡易版
443+//
444+void getViewPointFromWorldPoint2D(world_point2d wpoint, int* dest);
445+
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event_Menu.cpp (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event_Menu.cpp (revision 288)
@@ -87,7 +87,7 @@
8787 //setStatusBar(0, theApp.LevelNameList.GetAt(0));
8888
8989 //default zoom
90- theApp.zoomDivision = ZOOM_DIVISION_DEFAULT;
90+ theApp.gridManager->zoomReset();
9191
9292 //default position(center)
9393 OnItemCentering();
@@ -153,57 +153,12 @@
153153 }
154154 }
155155
156-//zoom in / out
157-void CMapEditorSDIView::addZoom(int step)
156+//拡大
157+void CMapEditorSDIView::OnZoomIn()
158158 {
159- int oldZoomDiv = theApp.zoomDivision;
160-
161- //拡大率が上がったら拡大率の増減速度を落とす
162- if( theApp.zoomDivision < 50){
163- step = hpl::math::sgn<int>(step);
164- }
165-
166- //拡大率増減
167- theApp.zoomDivision += step;
168-
169- //補正
170- if(theApp.zoomDivision < ZOOM_DIVISION_MIN){
171- theApp.zoomDivision = ZOOM_DIVISION_MIN;
172- }else if(theApp.zoomDivision > ZOOM_DIVISION_MAX){
173- theApp.zoomDivision = ZOOM_DIVISION_MAX;
174- }
175159 CRect rect;
176160 GetClientRect(&rect);
177-
178- POINT oldOffset = theApp.offset;
179- POINT center;
180- center.x = rect.Width() / 2;
181- center.y = rect.Height() / 2;
182- int newZoomDiv = theApp.zoomDivision;
183-
184- //拡大時は画面の中心ではなく表示領域の中心を真ん中として拡大縮小を行う
185- //そのためズレを補正する必要がある
186- int ax = center.x - oldOffset.x;
187- theApp.offset.x = center.x - (ax * oldZoomDiv / newZoomDiv);
188- int ay = center.y - oldOffset.y;
189- theApp.offset.y = center.y - (ay * oldZoomDiv / newZoomDiv);
190- /*
191- int delta = OFFSET_X_WORLD / theApp.zoomDivision -
192- //(rect.Width() / 2) +
193- OFFSET_X_WORLD / oldZoomDiv;
194- theApp.offset.x -= delta;
195- delta = OFFSET_Y_WORLD / theApp.zoomDivision -
196- //(rect.Height() / 2) +
197- OFFSET_Y_WORLD / oldZoomDiv;
198- theApp.offset.y -= delta;
199- */
200-}
201-
202-//拡大
203-void CMapEditorSDIView::OnZoomIn()
204-{
205- // TODO: ここにコマンド ハンドラ コードを追加します。
206- addZoom(-ZOOM_DIVISION_STEP);
161+ theApp.gridManager->zoomIn(rect.Width(), rect.Height());
207162 this->Invalidate(FALSE);
208163 }
209164
@@ -210,8 +165,9 @@
210165 //縮小
211166 void CMapEditorSDIView::OnZoomOut()
212167 {
213- // TODO: ここにコマンド ハンドラ コードを追加します。
214- addZoom(ZOOM_DIVISION_STEP);
168+ CRect rect;
169+ GetClientRect(&rect);
170+ theApp.gridManager->zoomOut(rect.Width(), rect.Height());
215171 this->Invalidate(FALSE);
216172 }
217173
@@ -219,8 +175,7 @@
219175 void CMapEditorSDIView::OnItemCentering()
220176 {
221177 // TODO: ここにコマンド ハンドラ コードを追加します。
222- theApp.offset.x = 0;
223- theApp.offset.y = 0;
178+ theApp.gridManager->setOffset(0,0);
224179 Invalidate(FALSE);
225180 }
226181 //拡大標準
@@ -227,7 +182,7 @@
227182 void CMapEditorSDIView::OnItemZoomDefault()
228183 {
229184 // TODO: ここにコマンド ハンドラ コードを追加します。
230- theApp.zoomDivision = ZOOM_DIVISION_DEFAULT;
185+ theApp.gridManager->zoomReset();
231186 Invalidate(FALSE);
232187 }
233188 //object info dialog on/off
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView.cpp (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView.cpp (revision 288)
@@ -105,9 +105,11 @@
105105 smallPen.CreatePen(PS_SOLID, 1, theApp.setting.getColorSetting()->gridLine);
106106 midiumPen.CreatePen(PS_SOLID, 2, theApp.setting.getColorSetting()->gridLine);
107107
108- int OFFSET_X_VIEW = theApp.offset.x;
109- int OFFSET_Y_VIEW = theApp.offset.y;
110- int DIV = theApp.zoomDivision;
108+ int offset[2];
109+ theApp.gridManager->getOffset(offset);
110+ int OFFSET_X_VIEW = offset[0];
111+ int OFFSET_Y_VIEW = offset[1];
112+ int DIV = theApp.gridManager->getZoomDivision();
111113
112114 for(int i = OFFSET_X_WORLD / DIV; i <= OFFSET_X_WORLD * 2 / DIV;
113115 i += theApp.gridIntervals[theApp.setting.getGridSizeIndex()] / DIV){
@@ -568,9 +570,11 @@
568570
569571 //範囲
570572 {
571- int OFFSET_X_VIEW = theApp.offset.x;
572- int OFFSET_Y_VIEW = theApp.offset.y;
573- int DIV = theApp.zoomDivision;
573+ int offset[2];
574+ theApp.gridManager->getOffset(offset);
575+ int OFFSET_X_VIEW = offset[0];
576+ int OFFSET_Y_VIEW = offset[1];
577+ int DIV = theApp.gridManager->getZoomDivision();
574578 int ICON_SIZE = 16;
575579
576580 CPen pen;
@@ -607,6 +611,8 @@
607611 //アノテーション(マップに表示される文字)の描画
608612 drawStrings(cdc);
609613
614+ int mpoint[2];
615+ theApp.gridManager->getNewMousePoint(mpoint);
610616 //選択範囲
611617 if(theApp.isSelectingGroup){
612618 bool selecting = true;
@@ -623,10 +629,12 @@
623629 cdc->SelectObject(&pen);
624630
625631 cdc->Rectangle(theApp.selectStartPoint.x, theApp.selectStartPoint.y,
626- theApp.nowMousePoint.x, theApp.nowMousePoint.y);
632+ mpoint[0], mpoint[1]);
627633
628634 pen.DeleteObject();
629635 }
636+
637+ //ポリゴン追加モードなら追加予定ポリゴンを表示?
630638 }
631639
632640 //裏画面をメインへ転送
@@ -943,6 +951,7 @@
943951
944952 theApp.selectDatas.clear();
945953
954+ int div = theApp.gridManager->getZoomDivision();
946955 for(std::map<int, endpoint_data>::iterator it = cpoints->begin();
947956 it != cpoints->end(); it ++){
948957 //コピー元のID
@@ -953,8 +962,8 @@
953962 memcpy(&ep, &cep, sizeof(endpoint_data));
954963
955964 //位置修正
956- ep.vertex.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
957- ep.vertex.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
965+ ep.vertex.x += theApp.storedDataPointDelta[0] * div;
966+ ep.vertex.y += theApp.storedDataPointDelta[1] * div;
958967
959968 //他は触らず。
960969 EndpointList.push_back(ep);
@@ -1013,8 +1022,8 @@
10131022 memcpy(&ep, &cep, sizeof(polygon_data));
10141023
10151024 //
1016- ep.center.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
1017- ep.center.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
1025+ ep.center.x += theApp.storedDataPointDelta[0] * div;
1026+ ep.center.y += theApp.storedDataPointDelta[1] * div;
10181027 for(int i = 0; i < ep.vertex_count; i ++){
10191028 ep.endpoint_indexes[i] = pointIndexTable[cep.endpoint_indexes[i]];
10201029 }
@@ -1046,8 +1055,8 @@
10461055 memcpy(&ep, &cep, sizeof(map_object));
10471056
10481057 //
1049- ep.location.x += theApp.storedDataPointDelta[0] * theApp.zoomDivision;
1050- ep.location.y += theApp.storedDataPointDelta[1] * theApp.zoomDivision;
1058+ ep.location.x += theApp.storedDataPointDelta[0] * theApp.gridManager->getZoomDivision();
1059+ ep.location.y += theApp.storedDataPointDelta[1] * theApp.gridManager->getZoomDivision();
10511060
10521061 SavedObjectList.push_back(ep);
10531062 int newIndex = (int)SavedObjectList.size() - 1;
--- marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event.cpp (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorSDIView_Event.cpp (revision 288)
@@ -7,6 +7,30 @@
77 #include "SelectLevelDialog.h"
88
99 /**
10+ 簡易バージョン
11+*/
12+void getViewPointFromWorldPoint2D(world_point2d wpoint, int* dest){
13+ int offset[2];
14+ theApp.gridManager->getOffset(offset);
15+ int div = theApp.gridManager->getZoomDivision();
16+ hpl::aleph::map::getViewPointFromWorldPoint2D(wpoint, dest, OFFSET_X_WORLD, OFFSET_Y_WORLD,
17+ div, offset[0], offset[1]);
18+}
19+void getViewPointFromWorldPoint2D(int x, int y, int* dest){
20+ world_point2d point = {x,y};
21+ getViewPointFromWorldPoint2D(point, dest);
22+}
23+world_point2d getWorldPoint2DFromViewPoint(int x, int y){
24+ int offset[2];
25+ theApp.gridManager->getOffset(offset);
26+ int div = theApp.gridManager->getZoomDivision();
27+ world_point2d wpoint = hpl::aleph::map::getWorldPoint2DFromViewPoint(x, y, OFFSET_X_WORLD, OFFSET_Y_WORLD, div, offset[0], offset[1]);
28+ return wpoint;
29+}
30+
31+//static void getWorldPointFromViewPoint2D(
32+
33+/**
1034 マウス座標が点に近いかどうかを調べて選択情報に設定
1135 @param mousePoint view座標系のマウスポイント座標
1236 @param offsetViewX view座標系のズレ補正
@@ -55,9 +79,11 @@
5579 */
5680 void CMapEditorSDIView::doLButtonDownDrawMode(UINT nFlags, CPoint &point)
5781 {
58- int OFFSET_X_VIEW = theApp.offset.x;
59- int OFFSET_Y_VIEW = theApp.offset.y;
60- int DIV = theApp.zoomDivision;
82+ int viewOffset[2];
83+ theApp.gridManager->getOffset(viewOffset);
84+ int OFFSET_X_VIEW = viewOffset[0];
85+ int OFFSET_Y_VIEW = viewOffset[1];
86+ int DIV = theApp.gridManager->getZoomDivision();
6187
6288 if(theApp.selectingToolType == TI_ARROW){
6389 //selecting tool = TI_ARROW
@@ -93,12 +119,13 @@
93119 //set pos to view
94120 int x = ep->vertex.x;
95121 int y = ep->vertex.y;
96- int drawX = (x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
97- int drawY = (y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
122+ //ビュー座標に変換
123+ int drawP[2];
124+ getViewPointFromWorldPoint2D(ep->vertex, drawP);
98125
99126 //sub to offset
100- selpoints->at(i).offset[0] = drawX - point.x;
101- selpoints->at(i).offset[1] = drawY - point.y;
127+ selpoints->at(i).offset[0] = drawP[0] - point.x;
128+ selpoints->at(i).offset[1] = drawP[1] - point.y;
102129 }
103130
104131 //lines
@@ -108,22 +135,18 @@
108135 line_data* line = &LineList[selData->index];
109136 endpoint_data* begin = &EndpointList[line->endpoint_indexes[0]];
110137 endpoint_data* end = &EndpointList[line->endpoint_indexes[1]];
138+ int beginViewP[2], endViewP[2];
139+ getViewPointFromWorldPoint2D(begin->vertex, beginViewP);
140+ getViewPointFromWorldPoint2D(end->vertex, endViewP);
111141 //set offsets
112- sellines->at(i).offset[0][0] =
113- (begin->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW
114- - point.x;
115- sellines->at(i).offset[0][1] =
116- (begin->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW
117- - point.y;
118- sellines->at(i).offset[1][0] =
119- (end->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW
120- - point.x;
121- sellines->at(i).offset[1][1] =
122- (end->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW
123- - point.y;
142+ sellines->at(i).offset[0][0] = beginViewP[0] - point.x;
143+ sellines->at(i).offset[0][1] = beginViewP[1] - point.y;
144+ sellines->at(i).offset[1][0] = endViewP[0] - point.x;
145+ sellines->at(i).offset[1][1] = endViewP[1] - point.y;
124146
125147 }
126148
149+ /*
127150 //polygons
128151 std::vector<struct hpl::aleph::map::SelPolygon>* selpolygons = theApp.selectDatas.getSelPolygons();
129152 for(int i = 0; i < (int)selpolygons->size(); i ++){
@@ -133,15 +156,13 @@
133156 int num = polygon->vertex_count;
134157 selpolygons->at(i).num = num;
135158 for(int j = 0; j < num; j ++){
136- int drawX = (EndpointList[polygon->endpoint_indexes[j]].vertex.x + OFFSET_X_WORLD) / DIV
137- + OFFSET_X_VIEW;
138- int drawY = (EndpointList[polygon->endpoint_indexes[j]].vertex.y + OFFSET_Y_WORLD) / DIV
139- + OFFSET_Y_VIEW;
140- selData->offset[j][0] = drawX - point.x;
141- selData->offset[j][1] = drawY - point.y;
159+ int drawViewP[2];
160+ hpl::aleph::map::getViewPointFromWorldPoint2D(EndpointList[polygon->endpoint_indexes[j]].vertex, drawViewP,
161+ OFFSET_X_WORLD, OFFSET_Y_WORLD, DIV, viewOffset[0], viewOffset[1]);
162+
142163 }
143164 }
144-
165+ */
145166 //objects
146167 std::vector<struct hpl::aleph::map::SelObject>* selobjects = theApp.selectDatas.getSelObjects();
147168 for(int i = 0; i < (int)selobjects->size(); i ++){
@@ -148,14 +169,12 @@
148169 struct hpl::aleph::map::SelObject* selData = &selobjects->at(i);
149170 map_object* obj = &SavedObjectList[selData->index];
150171 //set pos to view
151- int x = obj->location.x;
152- int y = obj->location.y;
153- int drawX = (x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
154- int drawY = (y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
172+ int drawViewP[2];
173+ getViewPointFromWorldPoint2D(obj->location.x, obj->location.y, drawViewP);
155174
156175 //sub to offset
157- selData->offset[0] = drawX - point.x;
158- selData->offset[1] = drawY - point.y;
176+ selData->offset[0] = drawViewP[0] - point.x;
177+ selData->offset[1] = drawViewP[1] - point.y;
159178 }
160179 }else{
161180 //release all selection
@@ -190,12 +209,12 @@
190209 x, y, OFFSET_X_VIEW, OFFSET_Y_VIEW,
191210 OFFSET_X_WORLD, OFFSET_Y_WORLD, DIV, OBJECT_DISTANCE_EPSILON))
192211 {
193- int drawX = (x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
194- int drawY = (y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
212+ int drawViewP[2];
213+ getViewPointFromWorldPoint2D(obj->location.x, obj->location.y, drawViewP);
195214
196215 int offset[2];
197- offset[0] = drawX - point.x;
198- offset[1] = drawY - point.y;
216+ offset[0] = drawViewP[0] - point.x;
217+ offset[1] = drawViewP[1] - point.y;
199218 theApp.selectDatas.addSelObject(i, offset);
200219 //選択したオブジェクトの情報を表示
201220 theApp.objectPropertyDialog->setupDialog(i);
@@ -216,7 +235,7 @@
216235 ////////////////////
217236 //points
218237 if(!theApp.selectDatas.isSelected()){
219- checkSelectPoint(point, OFFSET_X_VIEW, OFFSET_Y_VIEW,
238+ checkSelectPoint(point, viewOffset[0], viewOffset[1],
220239 OFFSET_X_WORLD, OFFSET_Y_WORLD, DIV, POINT_DISTANCE_EPSILON);
221240 }
222241 if(theApp.selectDatas.isSelected()){
@@ -238,16 +257,16 @@
238257 //オフセット記録
239258 int offset[2][2];
240259 offset[0][0] =
241- (begin->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW
260+ (begin->vertex.x + OFFSET_X_WORLD) / DIV + viewOffset[0]
242261 - point.x;
243262 offset[0][1] =
244- (begin->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW
263+ (begin->vertex.y + OFFSET_Y_WORLD) / DIV + viewOffset[1]
245264 - point.y;
246265 offset[1][0] =
247- (end->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW
266+ (end->vertex.x + OFFSET_X_WORLD) / DIV + viewOffset[0]
248267 - point.x;
249268 offset[1][1] =
250- (end->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW
269+ (end->vertex.y + OFFSET_Y_WORLD) / DIV + viewOffset[1]
251270 - point.y;
252271 theApp.selectDatas.addSelLine(i, offset);
253272
@@ -281,8 +300,7 @@
281300 //set offset
282301 for(int j = 0; j < num; j ++){
283302 int drawPoint[2];
284- getViewPointFromWorldPoint2D(EndpointList[polygon->endpoint_indexes[j]].vertex,
285- drawPoint);
303+ getViewPointFromWorldPoint2D(EndpointList[polygon->endpoint_indexes[j]].vertex, drawPoint);
286304 int drawX = drawPoint[0];
287305 int drawY = drawPoint[1];
288306 offset[j][0] = drawX - point.x;
@@ -390,7 +408,8 @@
390408 //show dialog
391409 CAnnotationDialog dlg(this);
392410 if(dlg.DoModal() == IDOK){
393- struct world_point2d world_point = getWorldPoint2DFromViewPoint(point.x, point.y);
411+ struct world_point2d world_point = hpl::aleph::map::getWorldPoint2DFromViewPoint(point.x, point.y,
412+ OFFSET_X_WORLD, OFFSET_Y_WORLD, DIV, OFFSET_X_VIEW, OFFSET_Y_VIEW);
394413
395414 int polygonIndex = getPolygonIdPointIn(world_point);
396415
@@ -453,12 +472,13 @@
453472 }else{
454473 theApp.isPressLButtonWithCtrl = false;
455474 }
456- theApp.nowMousePoint = point;
457- theApp.oldMousePoint = point;
475+ theApp.gridManager->setNewMousePoint(point.x, point.y);
458476
459- int OFFSET_X_VIEW = theApp.offset.x;
460- int OFFSET_Y_VIEW = theApp.offset.y;
461- int DIV = theApp.zoomDivision;
477+ int offset[2];
478+ theApp.gridManager->getOffset(offset);
479+ int OFFSET_X_VIEW = offset[0];
480+ int OFFSET_Y_VIEW = offset[1];
481+ int DIV = theApp.gridManager->getZoomDivision();
462482
463483
464484 switch(theApp.getEditMode()){
@@ -508,10 +528,15 @@
508528 }
509529
510530 void CMapEditorSDIView::moveMapOffset(int newPx, int newPy){
511- int deltaX = newPx - theApp.oldMousePoint.x;
512- int deltaY = newPy - theApp.oldMousePoint.y;
513- theApp.offset.x += deltaX;
514- theApp.offset.y += deltaY;
531+ int oldMousePoint[2];
532+ theApp.gridManager->getOldMousePoint(oldMousePoint);
533+ int deltaX = newPx - oldMousePoint[0];
534+ int deltaY = newPy - oldMousePoint[1];
535+ int offset[2];
536+ theApp.gridManager->getOffset(offset);
537+ offset[0] += deltaX;
538+ offset[1] += deltaY;
539+ theApp.gridManager->setOffset(offset[0], offset[1]);
515540 }
516541 /****************************************************************/
517542 //マウス移動
@@ -520,9 +545,11 @@
520545 setCursor();
521546
522547 // TODO: ここにメッセージ ハンドラ コードを追加するか、既定の処理を呼び出します。
523- theApp.nowMousePoint = point;
548+ theApp.gridManager->setNewMousePoint(point.x, point.y);
524549
525- const int DIV = theApp.zoomDivision;
550+ const int DIV = theApp.gridManager->getZoomDivision();
551+ int offset[2];
552+ theApp.gridManager->getOffset(offset);
526553 #ifdef MAP_VIEWER
527554 //クリックしていれば移動
528555 if(nFlags & MK_LBUTTON &&
@@ -546,8 +573,9 @@
546573 {
547574 //選択物の移動
548575 //world position of mouse pointer
549- int x = (point.x - theApp.offset.x) * theApp.zoomDivision - OFFSET_X_WORLD;
550- int y = (point.y - theApp.offset.y) * theApp.zoomDivision - OFFSET_Y_WORLD;
576+ world_point2d worldP = getWorldPoint2DFromViewPoint(point.x, point.y);
577+ int x = worldP.x; //(point.x - theApp.offset.x) * DIV - OFFSET_X_WORLD;
578+ int y = worldP.y; //(point.y - theApp.offset.y) * DIV - OFFSET_Y_WORLD;
551579 if(theApp.selectDatas.isSelected()){
552580 //グループを選択している
553581 //->グループを移動
@@ -614,7 +642,7 @@
614642 {
615643 continue;
616644 }
617- if(hpl::aleph::map::isSelectPoint(world_point, point->vertex, POINT_DISTANCE_EPSILON * theApp.zoomDivision))
645+ if(hpl::aleph::map::isSelectPoint(world_point, point->vertex, POINT_DISTANCE_EPSILON * theApp.gridManager->getZoomDivision()))
618646 {
619647 theApp.isNowOnThePoint = true;
620648 found = true;
@@ -634,7 +662,7 @@
634662 }// if/not ctrled
635663 #endif
636664 Invalidate(FALSE);
637- theApp.oldMousePoint = point;
665+ theApp.gridManager->setNewMousePoint(point.x, point.y);
638666
639667 CView::OnMouseMove(nFlags, point);
640668 }
@@ -672,11 +700,11 @@
672700 if(okSelect){
673701 //if selecting is only 1 object. setup property dialog
674702
703+ //int OFFSET_X_VIEW = theApp.offset.x;
704+ //int OFFSET_Y_VIEW = theApp.offset.y;
675705 theApp.selectDatas.clear();
676706
677- int DIV = theApp.zoomDivision;
678- int OFFSET_X_VIEW = theApp.offset.x;
679- int OFFSET_Y_VIEW = theApp.offset.y;
707+ int DIV = theApp.gridManager->getZoomDivision();
680708 //選択されているものをリストに登録する
681709 //点
682710 for(int i = 0; i < (int)EndpointList.size(); i ++){
@@ -683,8 +711,10 @@
683711 endpoint_data* ep = &EndpointList[i];
684712 int x = ep->vertex.x;
685713 int y = ep->vertex.y;
686- int drawX = (x + OFFSET_X_WORLD)/DIV + OFFSET_X_VIEW;
687- int drawY = (y + OFFSET_Y_WORLD)/DIV + OFFSET_Y_VIEW;
714+ int drawP[2];
715+ getViewPointFromWorldPoint2D(ep->vertex, drawP);
716+ int drawX = drawP[0];
717+ int drawY = drawP[1];
688718 //チェック
689719 if(hpl::math::isPointInRect<int>(drawX, drawY, point.x, point.y,
690720 theApp.selectStartPoint.x, theApp.selectStartPoint.y))
@@ -701,10 +731,13 @@
701731 line_data* line = &LineList[i];
702732 endpoint_data* begin = &EndpointList[line->endpoint_indexes[0]];
703733 endpoint_data* end = &EndpointList[line->endpoint_indexes[1]];
704- int x0 = (begin->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
705- int y0 = (begin->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
706- int x1 = (end->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
707- int y1 = (end->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
734+ int vpoint[2];
735+ getViewPointFromWorldPoint2D(begin->vertex, vpoint);
736+ int x0 = vpoint[0];
737+ int y0 = vpoint[1];
738+ getViewPointFromWorldPoint2D(end->vertex, vpoint);
739+ int x1 = vpoint[0];
740+ int y1 = vpoint[1];
708741 if(hpl::math::isLineInRect(x0, y0, x1, y1, point.x, point.y,
709742 theApp.selectStartPoint.x, theApp.selectStartPoint.y))
710743 {
@@ -726,8 +759,10 @@
726759 }
727760 for(int j = 0; j < vertexCount && inner; j ++){
728761 endpoint_data* ep = &EndpointList[polygon->endpoint_indexes[j]];
729- int drawX = (ep->vertex.x + OFFSET_X_WORLD) / DIV + OFFSET_X_VIEW;
730- int drawY = (ep->vertex.y + OFFSET_Y_WORLD) / DIV + OFFSET_Y_VIEW;
762+ int vpoint[2];
763+ getViewPointFromWorldPoint2D(ep->vertex, vpoint);
764+ int drawX = vpoint[0];
765+ int drawY = vpoint[1];
731766 if(!hpl::math::isPointInRect<int>(drawX, drawY, point.x, point.y,
732767 theApp.selectStartPoint.x, theApp.selectStartPoint.y))
733768 {
@@ -751,8 +786,10 @@
751786 map_object* obj = &SavedObjectList[i];
752787 int x = obj->location.x;
753788 int y = obj->location.y;
754- int drawX = (x + OFFSET_X_WORLD)/DIV + OFFSET_X_VIEW;
755- int drawY = (y + OFFSET_Y_WORLD)/DIV + OFFSET_Y_VIEW;
789+ int vpoint[2];
790+ getViewPointFromWorldPoint2D(obj->location.x, obj->location.y, vpoint);
791+ int drawX = vpoint[0];
792+ int drawY = vpoint[1];
756793
757794 //チェック
758795 if(hpl::math::isPointInRect<int>(drawX, drawY, point.x, point.y,
@@ -798,12 +835,12 @@
798835 {
799836 // TODO: ここにメッセージ ハンドラ コードを追加するか、既定の処理を呼び出します。
800837
801- theApp.nowMousePoint = point;
802- theApp.oldMousePoint = point;
803-
838+ theApp.gridManager->setNewMousePoint(point.x, point.y);
839+/*
804840 int OFFSET_X_VIEW = theApp.offset.x;
805841 int OFFSET_Y_VIEW = theApp.offset.y;
806- int DIV = theApp.zoomDivision;
842+ */
843+ int DIV = theApp.gridManager->getZoomDivision();
807844
808845 if(theApp.selectingToolType != TI_LINE){
809846 theApp.isFirstOfLineToAdd = true;
--- marathon/trunk/MapEditorOne/src/MapEditorOneInnerSetting.h (revision 287)
+++ marathon/trunk/MapEditorOne/src/MapEditorOneInnerSetting.h (revision 288)
@@ -10,6 +10,7 @@
1010 //#include <vector>
1111 #include <string>
1212 #include <map>
13+#include <vector>
1314
1415 namespace mapeditorone{
1516 namespace TagType{
--- marathon/trunk/HPLLib/HPLViewGridManager.cpp (revision 287)
+++ marathon/trunk/HPLLib/HPLViewGridManager.cpp (revision 288)
@@ -2,10 +2,19 @@
22 #include <memory.h>
33 #include "HPLMath.h"
44
5+/**
6+ ビューの次元
7+ the dimension of view window
8+*/
9+const int VIEW_DIMENSION = 2;
10+
511 hpl::aleph::view::HPLViewGridManager::HPLViewGridManager(ZoomProperties *zoomProp)
612 {
713 memcpy(&this->zoomProperties, zoomProp, sizeof(struct ZoomProperties));
8-
14+ //オフセット初期化
15+ this->viewOffset[0] = viewOffset[1] = 0;
16+ //割り算率初期化
17+ this->zoomReset();
918 }
1019
1120 hpl::aleph::view::HPLViewGridManager::~HPLViewGridManager()
@@ -35,7 +44,16 @@
3544 {
3645 this->addZoom(this->zoomProperties.zoomDivisionStep, viewW, viewH);
3746 }
47+/**
48+ 拡大率初期化
49+*/
50+void hpl::aleph::view::HPLViewGridManager::zoomReset()
51+{
52+ this->zoomDivision = this->zoomProperties.zoomDivisionDefault;
53+}
3854
55+
56+
3957 /**
4058 ズーム調整
4159 @param step 変化量
@@ -67,3 +85,41 @@
6785 int ay = center[1] - oldOffset[1];
6886 this->viewOffset[1] = center[1] - ay * oldZoomDiv / newZoomDiv;
6987 }
88+
89+//void setOldMousePoint(int x, int y);
90+/**
91+ マウス座標をセットします
92+ set mouse position info (view coordinate)
93+*/
94+void hpl::aleph::view::HPLViewGridManager::setNewMousePoint(int x, int y)
95+{
96+ for(int i = 0; i < VIEW_DIMENSION; i ++){
97+ this->oldMousePoint[i] = this->newMousePoint[i];
98+ }
99+ this->newMousePoint[0] = x;
100+ this->newMousePoint[1] = y;
101+}
102+void hpl::aleph::view::HPLViewGridManager::getNewMousePoint(int* point)
103+{
104+ for(int i = 0; i < VIEW_DIMENSION; i ++){
105+ point[i] = this->newMousePoint[i];
106+ }
107+}
108+void hpl::aleph::view::HPLViewGridManager::getOldMousePoint(int* point)
109+{
110+ for(int i = 0; i < VIEW_DIMENSION; i ++){
111+ point[i] = this->oldMousePoint[i];
112+ }
113+}
114+
115+void hpl::aleph::view::HPLViewGridManager::setOffset(int x, int y)
116+{
117+ this->viewOffset[0] = x;
118+ this->viewOffset[1] = y;
119+}
120+void hpl::aleph::view::HPLViewGridManager::getOffset(int* point)
121+{
122+ for(int i = 0; i < VIEW_DIMENSION; i ++){
123+ point[i] = this->viewOffset[i];
124+ }
125+}
--- marathon/trunk/HPLLib/HPLViewGridManager.h (revision 287)
+++ marathon/trunk/HPLLib/HPLViewGridManager.h (revision 288)
@@ -7,6 +7,15 @@
77 #ifndef _HPL_VIEW_GRID_MANAGER_
88 #define _HPL_VIEW_GRID_MANAGER_
99
10+const int NUMBER_OF_GLID = 5;
11+const int ZOOM_DIVISION_STEP = 5;
12+const int ZOOM_DIVISION_MAX = 200;
13+const int ZOOM_DIVISION_MIN = 1;
14+const int ZOOM_DIVISION_DEFAULT = 100;
15+const int OFFSET_X_WORLD = 32768;
16+const int OFFSET_Y_WORLD = 32768;
17+
18+
1019 namespace hpl{
1120 namespace aleph{
1221 namespace view{
@@ -28,6 +37,8 @@
2837
2938 /**初期値・規定値*/
3039 int zoomDivisionDefault;
40+
41+ int gridIntervals[NUMBER_OF_GLID];
3142 };
3243 /**
3344 拡大縮小、スクロールなどの管理
@@ -42,6 +53,9 @@
4253
4354 /**View座標のオフセット*/
4455 int viewOffset[2];
56+
57+ int oldMousePoint[2];
58+ int newMousePoint[2];
4559 public:
4660 HPLViewGridManager(ZoomProperties *zoomProp);
4761 ~HPLViewGridManager();
@@ -62,6 +76,23 @@
6276 zoom out
6377 */
6478 void zoomOut(int viewW, int viewH);
79+
80+ /**
81+ 拡大率初期化
82+ */
83+ void zoomReset();
84+
85+ //void setOldMousePoint(int x, int y);
86+ /**
87+ マウス座標をセットします
88+ set mouse position info (view coordinate)
89+ */
90+ void setNewMousePoint(int x, int y);
91+ void getNewMousePoint(int* point);
92+ void getOldMousePoint(int* point);
93+
94+ void setOffset(int x, int y);
95+ void getOffset(int* point);
6596 private:
6697 /**
6798 ズーム調整
旧リポジトリブラウザで表示