Compare commits

...

7 Commits

27 changed files with 240 additions and 103 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -143,13 +143,12 @@
<attstr name="font" val="medium"/>
</section>
<!--
<section name="MaxRefreshRateCombo">
<attstr name="type" val="combo box"/>
<attnum name="max len" val="4"/>
<attstr name="tip" val="Select your max. refresh rate"/>
<attnum name="x" val="320"/>
<attnum name="y" val="158"/>
<attnum name="x" val="270"/>
<attnum name="y" val="228"/>
<attnum name="width" val="220"/>
<attnum name="arrows width" val="24"/>
<attnum name="arrows height" val="24"/>
@ -157,7 +156,6 @@
<attstr name="focused color" val="0xFFFFFF"/>
<attstr name="font" val="medium"/>
</section>
-->
<section name="CancelButton">
<attstr name="type" val="text button"/>
@ -315,6 +313,17 @@
<attstr name="font" val="small_t"/>
</section>
<section name="12">
<attstr name="type" val="label"/>
<attnum name="x" val="20"/>
<attnum name="y" val="232"/>
<attstr name="text" val="Max FPS:"/>
<attstr name="tip" val="Sets maximum frames per second rate"/>
<attstr name="h align" val="right"/>
<attnum name="width" val="220"/>
<attstr name="font" val="small_t"/>
</section>
</section>
</params>

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -278,9 +278,4 @@ void GfEventLoop::recompute()
// Call the 'recompute' callback if any.
if (_pPrivate->cbRecompute)
_pPrivate->cbRecompute();
// ... otherwise let the CPU take breath (and fans stay at low and quiet speed,
// which would not be the case if really doing nothing).
else
SDL_Delay(1); // ms.
}

View File

@ -19,6 +19,7 @@
#include <SDL.h>
#include "tgfclient.h"
#include "tgf.h"
#ifdef WEBSERVER
#include "webserver.h"
@ -48,12 +49,14 @@ class GfuiEventLoop::Private
// Variables.
bool bRedisplay; // Flag to say if a redisplay is necessary.
double max_refresh; // Max refresh rate.
};
GfuiEventLoop::Private::Private()
: cbMouseButton(0), cbMouseMotion(0), cbMousePassiveMotion(0), cbMouseWheel(0),
cbJoystickAxis(0), cbJoystickButton(0),
cbDisplay(0), cbReshape(0), bRedisplay(false)
cbDisplay(0), cbReshape(0), bRedisplay(false),
max_refresh(50.0)
{
}
@ -238,11 +241,22 @@ void GfuiEventLoop::operator()()
if (!quitRequested())
{
double now = GfTimeClock();
// Recompute if anything to.
recompute();
// Redisplay if anything to.
redisplay();
double elapsed = GfTimeClock() - now;
if (_pPrivate->max_refresh)
{
double rate = 1.0 / _pPrivate->max_refresh;
if (elapsed < rate)
GfSleep(rate - elapsed);
}
}
}
@ -294,6 +308,11 @@ void GfuiEventLoop::postRedisplay(void)
_pPrivate->bRedisplay = true;
}
void GfuiEventLoop::setMaxRefreshRate(double rate)
{
_pPrivate->max_refresh = rate;
}
void GfuiEventLoop::forceRedisplay()
{
#ifdef WEBSERVER

View File

@ -207,6 +207,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
tScreenSize last;
last.width = 0;
last.height = 0;
last.refresh_rate = 0;
bounds.w = 0;
bounds.h = 0;
@ -240,6 +241,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
GfLogDebug(" %d x %d x %d @ %d hz\n",mode.w,mode.h,SDL_BITSPERPIXEL(mode.format),mode.refresh_rate);
last.width = mode.w;
last.height = mode.h;
last.refresh_rate = mode.refresh_rate;
vecSizes.push_back(last);
}
}
@ -259,6 +261,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
// Desperation stick the Display Bounds into the vector
last.width = bounds.w;
last.height = bounds.h;
last.refresh_rate = mode.refresh_rate;
vecSizes.push_back(last);
}
@ -276,12 +279,14 @@ tScreenSize GfScrGetCurrentDisplaySize(int nDisplayIndex)
size.width = 0;
size.height = 0;
size.refresh_rate = 0;
SDL_DisplayMode mode;
if(SDL_GetCurrentDisplayMode(nDisplayIndex, &mode) == 0)
{
size.width = mode.w;
size.height = mode.h;
size.refresh_rate = mode.refresh_rate;
}
return size;
}
@ -490,6 +495,10 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
GfScrStartDisplayId = 0;
}
double maxRefreshRate = GfParmGetNum(hparmScreen, pszScrPropSec, GFSCR_ATT_MAXREFRESH, NULL, 50);
GfuiApp().eventLoop().setMaxRefreshRate(maxRefreshRate);
bool bFullScreen;
if (nFullScreen < 0)
bFullScreen =
@ -723,6 +732,7 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
GfLogInfo(" Full screen : %s\n", (bfVideoMode & SDL_WINDOW_FULLSCREEN) ? "Yes" : "No");
GfLogInfo(" Size : %dx%d\n", nWinWidth, nWinHeight);
GfLogInfo(" Color depth : %d bits\n", nTotalDepth);
GfLogInfo(" Max. refresh rate : %f\n", maxRefreshRate);
// Report about underlying hardware (needs a running frame buffer).
GfglFeatures::self().dumpHardwareInfo();
@ -804,6 +814,8 @@ void GfScrShutdown(void)
GfParmGetNum(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_STARTUPDISPLAY, 0, 0));
GfParmSetStr(hparmScreen, GFSCR_SECT_VALIDPROPS, GFSCR_ATT_VDETECT,
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VDETECT, GFSCR_VAL_VDETECT_AUTO));
GfParmSetNum(hparmScreen, GFSCR_SECT_VALIDPROPS, GFSCR_ATT_MAXREFRESH, 0,
GfParmGetNum(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_MAXREFRESH, 0, 50));
const char* pszVInitMode =
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VINIT,
GFSCR_VAL_VINIT_COMPATIBLE);
@ -1259,6 +1271,20 @@ bool GfScrInitSDL2()
// Setup the event loop about the new display.
GfuiApp().eventLoop().setReshapeCB(gfScrReshapeViewport);
GfuiApp().eventLoop().postRedisplay();
double maxRefreshRate = 50;
void* hparmScreen =
GfParmReadFileLocal(GFSCR_CONF_FILE, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
if (hparmScreen)
{
maxRefreshRate = GfParmGetNum(hparmScreen,
GFSCR_SECT_VALIDPROPS, GFSCR_ATT_MAXREFRESH, NULL, maxRefreshRate);
GfParmReleaseHandle(hparmScreen);
}
GfuiApp().eventLoop().setMaxRefreshRate(maxRefreshRate);
return true;
}
else

View File

@ -75,6 +75,7 @@ typedef struct ScreenSize
{
int width; // Width in pixels.
int height; // Height in pixels.
double refresh_rate; // Refresh rate in Hz.
} tScreenSize;
typedef std::vector<tScreenSize> ScreenSizeVector;
@ -768,6 +769,9 @@ class TGFCLIENT_API GfuiEventLoop : public GfEventLoop
//! Force a call to the "redisplay/refresh" callback function.
void forceRedisplay();
//! Sets maximum refresh rate to the event loop.
void setMaxRefreshRate(double rate);
protected:
//! Process a keyboard event.

View File

@ -486,9 +486,6 @@ configure_for_joy_axis:
return;
}
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
/* Push button callback for each command button : activate input devices action collection loop */

View File

@ -33,10 +33,8 @@ static const char* ADisplayModes[DisplayMenu::nDisplayModes] = { "Full-screen",
static const char* MonitorTypes[DisplayMenu::nDisplayTypes] = { "none", "4:3", "16:9", "21:9" };
static const char* SpansplitValues[] = { GR_VAL_NO, GR_VAL_YES };
static const int NbSpansplitValues = sizeof(SpansplitValues) / sizeof(SpansplitValues[0]);
#ifndef NoMaxRefreshRate
static const int AMaxRefreshRates[] = { 0, 30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
static const int AMaxRefreshRates[] = {30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefreshRates[0]);
#endif
// The unique DisplayMenu instance.
static DisplayMenu* PDisplayMenu = 0;
@ -155,7 +153,6 @@ void DisplayMenu::onChangeMenuDisplay(tComboBoxInfo *pInfo)
pMenu->setMenuDisplay(pInfo->nPos);
}
#ifndef NoMaxRefreshRate
void DisplayMenu::onChangeMaxRefreshRate(tComboBoxInfo *pInfo)
{
// Get the DisplayMenu instance from call-back user data.
@ -163,7 +160,6 @@ void DisplayMenu::onChangeMaxRefreshRate(tComboBoxInfo *pInfo)
pMenu->setMaxRefreshRateIndex(pInfo->nPos);
}
#endif
// Re-init screen to take new graphical settings into account (implies process restart).
void DisplayMenu::onAccept(void *pDisplayMenu)
@ -202,7 +198,8 @@ bool DisplayMenu::restartNeeded()
bool needRestart = ((_eDisplayMode != _eOriginalDisplayMode)
|| (_nScreenWidth !=_nOriginalScreenWidth)
|| (_nScreenHeight != _nOriginalScreenHeight)
|| (_nOriginalMenuDisplay != _nMenuDisplay));
|| (_nOriginalMenuDisplay != _nMenuDisplay))
|| (_nOriginalMaxRefreshRate != _nMaxRefreshRate);
if(GfScrUsingResizableWindow() && (_eDisplayMode == eResizable))
needRestart = false;
@ -261,7 +258,6 @@ void DisplayMenu::updateControls()
sprintf(buf, "%g", PDisplayMenu->_fArcRatio);
GfuiEditboxSetString(getMenuHandle(), sArcRatioID, buf);
#ifndef NoMaxRefreshRate
nControlId = getDynamicControlId("MaxRefreshRateCombo");
int nMaxRefRateIndex = 0; // Defaults to None.
for (int nMaxRefRateInd = 0; nMaxRefRateInd < NMaxRefreshRates; nMaxRefRateInd++)
@ -271,7 +267,6 @@ void DisplayMenu::updateControls()
break;
}
GfuiComboboxSetSelectedIndex(getMenuHandle(), nControlId, nMaxRefRateIndex);
#endif
}
void DisplayMenu::loadSettings()
@ -303,11 +298,9 @@ void DisplayMenu::loadSettings()
}
#ifndef NoMaxRefreshRate
// Max. refresh rate (Hz).
_nMaxRefreshRate =
(int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_MAXREFRESH, NULL, 0);
#endif
_nMaxRefreshRate = _nOriginalMaxRefreshRate =
(int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_MAXREFRESH, NULL, 50);
// Release screen config params file.
GfParmReleaseHandle(hScrConfParams);
@ -328,9 +321,7 @@ void DisplayMenu::storeSettings() const
GfParmSetNum(hScrConfParams, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_WIN_X, (char*)NULL, _nScreenWidth);
GfParmSetNum(hScrConfParams, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_WIN_Y, (char*)NULL, _nScreenHeight);
GfParmSetNum(hScrConfParams, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_STARTUPDISPLAY, (char*)NULL, _nMenuDisplay);
#ifndef NoMaxRefreshRate
GfParmSetNum(hScrConfParams, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_MAXREFRESH, (char*)NULL, _nMaxRefreshRate);
#endif
const char* pszDisplMode =
(_eDisplayMode == eFullScreen) ? GFSCR_VAL_YES : GFSCR_VAL_NO;
@ -468,6 +459,7 @@ void DisplayMenu::resetScreenSizes()
tScreenSize _currSize = GfScrGetCurrentDisplaySize( _nMenuDisplay);
_nScreenWidth = _currSize.width;
_nScreenHeight = _currSize.height;
_nMaxRefreshRate = _currSize.refresh_rate;
}
else
{
@ -520,6 +512,20 @@ void DisplayMenu::resetScreenSizes()
// Select the found one in the combo-box.
GfuiComboboxSetSelectedIndex(getMenuHandle(), nComboId, nScreenSizeIndex);
{
const int nComboId = getDynamicControlId("MaxRefreshRateCombo");
if (nComboId != -1)
for (size_t i = 0; i < NMaxRefreshRates; i++)
{
if (AMaxRefreshRates[i] == _nMaxRefreshRate)
{
GfuiComboboxSetSelectedIndex(getMenuHandle(), nComboId, i);
break;
}
}
}
}
void DisplayMenu::setScreenSizeIndex(int nIndex)
@ -562,12 +568,10 @@ void DisplayMenu::setMenuDisplay(int nIndex)
}
}
#ifndef NoMaxRefreshRate
void DisplayMenu::setMaxRefreshRateIndex(int nIndex)
{
_nMaxRefreshRate = AMaxRefreshRates[nIndex];
}
#endif
DisplayMenu::DisplayMenu()
: GfuiMenuScreen("displayconfigmenu.xml")
@ -585,9 +589,7 @@ DisplayMenu::DisplayMenu()
_nOriginalScreenHeight = 600;
_nOriginalMenuDisplay = 0;
_eOriginalDisplayMode = eWindowed;
#ifndef NoMaxRefreshRate
_nMaxRefreshRate = 0;
#endif
_nMaxRefreshRate = 50;
}
bool DisplayMenu::initialize(void *pPreviousMenu)
@ -635,10 +637,8 @@ bool DisplayMenu::initialize(void *pPreviousMenu)
sArcRatioID = createEditControl("arcratioedit", this, NULL, onChangeArcRatio);
#ifndef NoMaxRefreshRate
const int nMaxRefRateComboId =
createComboboxControl("MaxRefreshRateCombo", this, onChangeMaxRefreshRate);
#endif
createButtonControl("ApplyButton", this, onAccept);
createButtonControl("CancelButton", this, onCancel);
@ -668,7 +668,6 @@ bool DisplayMenu::initialize(void *pPreviousMenu)
GfuiComboboxAddText(getMenuHandle(), nSpanSplitsComboId, SpansplitValues[index]);
#ifndef NoMaxRefreshRate
// 6) Max refresh rate combo.
std::ostringstream ossMaxRefRate;
for (int nRefRateInd = 0; nRefRateInd < NMaxRefreshRates; nRefRateInd++)
@ -680,7 +679,6 @@ bool DisplayMenu::initialize(void *pPreviousMenu)
ossMaxRefRate << "None";
GfuiComboboxAddText(getMenuHandle(), nMaxRefRateComboId, ossMaxRefRate.str().c_str());
}
#endif
return true;
}

View File

@ -25,8 +25,6 @@
#include "confscreens.h"
// Comment-out to activate max. refresh rate settings.
#define NoMaxRefreshRate 1
class DisplayMenu : public GfuiMenuScreen
@ -46,9 +44,7 @@ public:
void setMonitorType(EDisplayType eType);
void setArcRatio(float ratio);
void setMenuDisplay(int nIndex);
#ifndef NoMaxRefreshRate
void setMaxRefreshRateIndex(int nIndex);
#endif
void storeSettings() const;
void loadSettings();
@ -76,9 +72,7 @@ protected:
static void onChangeScreenDist(void *pDisplayMenu);
static void onChangeArcRatio(void *pDisplayMenu);
static void onChangeMenuDisplay(tComboBoxInfo *pInfo);
#ifndef NoMaxRefreshRate
static void onChangeMaxRefreshRate(tComboBoxInfo *pInfo);
#endif
static void onAccept(void *pDisplayMenu);
static void onCancel(void *pDisplayMenu);
@ -108,10 +102,9 @@ private:
float _fScreenDist;
#ifndef NoMaxRefreshRate
//! Currently selected max. refresh rate (Hz).
int _nMaxRefreshRate;
#endif
int _nOriginalMaxRefreshRate;
};
extern void* DisplayMenuInit(void* pPreviousMenu);

View File

@ -279,9 +279,6 @@ Idle2(void)
return;
}
}
/* Let CPU take breath (and fans stay at low and quite speed) */
GfSleep(0.001);
}

View File

@ -195,9 +195,6 @@ Idle2(void)
return;
}
}
/* Let CPU take breath (and fans stay at low and quite speed) */
GfSleep(0.001);
}

View File

@ -163,9 +163,6 @@ Idle2(void)
return;
}
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
static void

View File

@ -95,11 +95,6 @@ static void splashIdle()
// And now it's done, remember it.
splBackgroundWorkDone = true;
}
else
{
// Wait a little, to let the CPU take breath.
GfSleep(0.001);
}
// Close if the splash screen delay is over.
if (splTimedOut)

View File

@ -543,9 +543,6 @@ HostServerIdle(void)
GfuiApp().eventLoop().postRedisplay();
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
@ -580,9 +577,6 @@ ClientIdle(void)
GfuiApp().eventLoop().postRedisplay();
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
static void

View File

@ -541,9 +541,6 @@ HostServerIdle(void)
GfuiApp().eventLoop().postRedisplay();
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
@ -578,9 +575,6 @@ ClientIdle(void)
GfuiApp().eventLoop().postRedisplay();
}
/* Let CPU take breath (and fans stay at low and quiet speed) */
GfSleep(0.001);
}
static void

View File

@ -23,6 +23,7 @@ package gui.properties;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@ -31,6 +32,7 @@ import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
@ -530,6 +532,29 @@ public class TerrainProperties extends PropertyPanel
private JButton objectMapButton = null;
private ObjectTablePanel objectTablePanel = null;
public class Data
{
String name;
Integer color;
Integer x;
Integer y;
Data(String name, Integer color, Integer x, Integer y)
{
this.name = name;
this.color = color;
this.x = x;
this.y = y;
}
}
private Vector<Data> data = new Vector<Data>();
public Vector<Data> getData()
{
return data;
}
/**
*
*/
@ -598,15 +623,72 @@ public class TerrainProperties extends PropertyPanel
UIManager.put("FileChooser.readOnly", old);
if (result == JFileChooser.APPROVE_OPTION)
{
String fileName = fc.getSelectedFile().toString();
int index = fileName.lastIndexOf(sep);
String pathToFile = fileName.substring(0, index);
String selectedFile = fc.getSelectedFile().toString();
String fileName = selectedFile;
int index = selectedFile.lastIndexOf(sep);
String pathToFile = selectedFile.substring(0, index);
if (pathToFile.equals(Editor.getProperties().getPath()))
fileName = fileName.substring(index + 1);
fileName = selectedFile.substring(index + 1);
objectMapTextField.setText(fileName);
// update table with new data
try
{
getDataFromImage(selectedFile);
objectTablePanel.dataChanged();
}
catch (IOException e)
{
}
}
}
public void getDataFromImage(String fileName) throws IOException
{
data.clear();
File file = new File(fileName);
if (file.exists())
{
BufferedImage image = ImageIO.read(file);
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
for (int x = 0; x < imageWidth; x++)
{
for (int y = 0; y < imageHeight; y++)
{
int rgb = image.getRGB(x, y) & 0x00ffffff;
if (rgb != 0x0)
{
String name = getEditorFrame().getObjectColorName(rgb);
if (name == null)
{
name = new String("Unknown");
}
data.add(new Data(name, rgb, x, y));
}
}
}
}
}
public void getDataFromObjectMap(ObjectMap objectMap)
{
data.clear();
for (int i = 0; i < objectMap.getObjects().size(); i++)
{
ObjShapeObject object = objectMap.getObjects().get(i);
data.add(new Data(new String(object.getName()), object.getRGB(), object.getImageX(), object.getImageY()));
}
}
private ObjectTablePanel getObjectTablePanel(ObjectMap objectMap)
{
if (objectTablePanel == null)
@ -656,33 +738,11 @@ public class TerrainProperties extends PropertyPanel
{
Integer.class, String.class, Integer.class, Integer.class, Integer.class
};
class Data
{
String name;
Integer color;
Integer x;
Integer y;
Data(String name, Integer color, Integer x, Integer y)
{
this.name = name;
this.color = color;
this.x = x;
this.y = y;
}
}
private Vector<Data> data = new Vector<Data>();
ObjectTableModel(ObjectMap objectMap)
ObjectTableModel(ObjectMap objectMap)
{
for (int i = 0; i < objectMap.getObjects().size(); i++)
{
ObjShapeObject object = objectMap.getObjects().get(i);
data.add(new Data(new String(object.getName()), object.getRGB(), object.getImageX(), object.getImageY()));
}
}
getDataFromObjectMap(objectMap);
}
public int getRowCount()
{
@ -724,7 +784,7 @@ public class TerrainProperties extends PropertyPanel
case 0:
return rowIndex + 1;
case 1:
return getEditorFrame().getObjectColorName(datum.color);
return datum.name;
case 2:
return String.format("0x%06X", datum.color);
case 3:
@ -780,12 +840,17 @@ public class TerrainProperties extends PropertyPanel
class ObjectTablePanel extends JPanel
{
public ObjectTablePanel(ObjectMap objectMap)
JTable table = null;
JScrollPane scrollPane = null;
ObjectTableModel model = null;
public ObjectTablePanel(ObjectMap objectMap)
{
super(new GridLayout(1,0));
JTable table = new JTable(new ObjectTableModel(objectMap));
JScrollPane scrollPane = new JScrollPane(table);
model = new ObjectTableModel(objectMap);
table = new JTable(model);
scrollPane = new JScrollPane(table);
table.getColumnModel().getColumn(0).setPreferredWidth(25);
table.setDefaultRenderer(Integer.class, new ColorRenderer());
@ -795,6 +860,11 @@ public class TerrainProperties extends PropertyPanel
add(scrollPane);
}
void dataChanged()
{
model.fireTableDataChanged();
}
}
}
@ -924,6 +994,56 @@ public class TerrainProperties extends PropertyPanel
}
getEditorFrame().documentIsModified = true;
}
Vector<ObjectMapPanel.Data> data = panel.getData();
Vector<ObjShapeObject> objects = objectMap.getObjects();
int minDataCount = Math.min(data.size(), objects.size());
if (data.size() != objects.size())
{
getEditorFrame().documentIsModified = true;
}
for (int j = 0; j < minDataCount; j++)
{
ObjectMapPanel.Data datum = data.get(j);
ObjShapeObject object = objects.get(j);
if (!datum.color.equals(object.getRGB()))
{
object.setRGB(datum.color);
getEditorFrame().documentIsModified = true;
}
if (!datum.x.equals(object.getImageX()))
{
object.setImageX(datum.x);
getEditorFrame().documentIsModified = true;
}
if (!datum.y.equals(object.getImageY()))
{
object.setImageY(datum.y);
getEditorFrame().documentIsModified = true;
}
}
if (data.size() < objects.size())
{
// need to trim objects
while (objects.size() > data.size())
{
objects.remove(objects.size() - 1);
}
}
else if (objects.size() < data.size())
{
// need to add to objects
while (objects.size() < data.size())
{
ObjectMapPanel.Data datum = data.get(objects.size());
objects.add(new ObjShapeObject(datum.color, datum.x, datum.y));
}
}
}
if (objectMaps.size() > tabbedPane.getTabCount())
{

View File

@ -35,6 +35,7 @@ public class ObjShapeObject extends Segment
public void setRGB(int rgb) {
this.rgb = rgb;
this.color = new Color((rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff);
}
public Color getColor() {
@ -43,6 +44,7 @@ public class ObjShapeObject extends Segment
public void setColor(Color color) {
this.color = color;
this.rgb = color.getRGB();
}
public int getImageX() {