forked from mirror/openmw-tes3mp
toggleFogOfWar script command
This commit is contained in:
parent
0c2317ce9d
commit
8d224f009f
7 changed files with 62 additions and 9 deletions
|
@ -278,6 +278,7 @@ LocalMapBase::LocalMapBase()
|
||||||
: mCurX(0)
|
: mCurX(0)
|
||||||
, mCurY(0)
|
, mCurY(0)
|
||||||
, mInterior(false)
|
, mInterior(false)
|
||||||
|
, mFogOfWar(true)
|
||||||
, mLocalMap(NULL)
|
, mLocalMap(NULL)
|
||||||
, mPrefix()
|
, mPrefix()
|
||||||
, mChanged(true)
|
, mChanged(true)
|
||||||
|
@ -297,6 +298,32 @@ void LocalMapBase::setCellPrefix(const std::string& prefix)
|
||||||
mChanged = true;
|
mChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalMapBase::toggleFogOfWar()
|
||||||
|
{
|
||||||
|
mFogOfWar = !mFogOfWar;
|
||||||
|
applyFogOfWar();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalMapBase::applyFogOfWar()
|
||||||
|
{
|
||||||
|
for (int mx=0; mx<3; ++mx)
|
||||||
|
{
|
||||||
|
for (int my=0; my<3; ++my)
|
||||||
|
{
|
||||||
|
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
|
||||||
|
+ boost::lexical_cast<std::string>(my);
|
||||||
|
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_"
|
||||||
|
+ boost::lexical_cast<std::string>(mCurY + (mInterior ? (my-1) : -1*(my-1)));
|
||||||
|
MyGUI::ImageBox* fog;
|
||||||
|
mLayout->getWidget(fog, name+"_fog");
|
||||||
|
fog->setImageTexture(mFogOfWar ?
|
||||||
|
((MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) ? image+"_fog"
|
||||||
|
: "black.png" )
|
||||||
|
: "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||||
{
|
{
|
||||||
if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell
|
if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell
|
||||||
|
@ -312,23 +339,17 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||||
|
|
||||||
MyGUI::ImageBox* box;
|
MyGUI::ImageBox* box;
|
||||||
mLayout->getWidget(box, name);
|
mLayout->getWidget(box, name);
|
||||||
MyGUI::ImageBox* fog;
|
|
||||||
mLayout->getWidget(fog, name+"_fog");
|
|
||||||
|
|
||||||
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)
|
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)
|
||||||
box->setImageTexture(image);
|
box->setImageTexture(image);
|
||||||
else
|
else
|
||||||
box->setImageTexture("black.png");
|
box->setImageTexture("black.png");
|
||||||
|
|
||||||
if (MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0)
|
|
||||||
fog->setImageTexture(image+"_fog");
|
|
||||||
else
|
|
||||||
fog->setImageTexture("black.png");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mInterior = interior;
|
mInterior = interior;
|
||||||
mCurX = x;
|
mCurX = x;
|
||||||
mCurY = y;
|
mCurY = y;
|
||||||
mChanged = false;
|
mChanged = false;
|
||||||
|
applyFogOfWar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,17 @@ namespace MWGui
|
||||||
void setCellPrefix(const std::string& prefix);
|
void setCellPrefix(const std::string& prefix);
|
||||||
void setActiveCell(const int x, const int y, bool interior=false);
|
void setActiveCell(const int x, const int y, bool interior=false);
|
||||||
|
|
||||||
|
void toggleFogOfWar();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int mCurX, mCurY;
|
int mCurX, mCurY;
|
||||||
bool mInterior;
|
bool mInterior;
|
||||||
MyGUI::ScrollView* mLocalMap;
|
MyGUI::ScrollView* mLocalMap;
|
||||||
std::string mPrefix;
|
std::string mPrefix;
|
||||||
bool mChanged;
|
bool mChanged;
|
||||||
|
bool mFogOfWar;
|
||||||
|
|
||||||
|
void applyFogOfWar();
|
||||||
|
|
||||||
OEngine::GUI::Layout* mLayout;
|
OEngine::GUI::Layout* mLayout;
|
||||||
};
|
};
|
||||||
|
|
|
@ -469,3 +469,9 @@ void WindowManager::setPlayerDir(const float x, const float y)
|
||||||
map->setPlayerDir(x,y);
|
map->setPlayerDir(x,y);
|
||||||
hud->setPlayerDir(x,y);
|
hud->setPlayerDir(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::toggleFogOfWar()
|
||||||
|
{
|
||||||
|
map->toggleFogOfWar();
|
||||||
|
hud->toggleFogOfWar();
|
||||||
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ namespace MWGui
|
||||||
void setPlayerPos(const float x, const float y); ///< set player position in map space
|
void setPlayerPos(const float x, const float y); ///< set player position in map space
|
||||||
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
|
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
|
||||||
|
|
||||||
|
void toggleFogOfWar();
|
||||||
|
|
||||||
void setInteriorMapTexture(const int x, const int y);
|
void setInteriorMapTexture(const int x, const int y);
|
||||||
///< set the index of the map texture that should be used (for interiors)
|
///< set the index of the map texture that should be used (for interiors)
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,6 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3&
|
||||||
u = std::abs((pos.x - (sSize*x))/sSize);
|
u = std::abs((pos.x - (sSize*x))/sSize);
|
||||||
v = 1-std::abs((pos.y + (sSize*y))/sSize);
|
v = 1-std::abs((pos.y + (sSize*y))/sSize);
|
||||||
texName = "Cell_"+coordStr(x,y);
|
texName = "Cell_"+coordStr(x,y);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,4 +123,5 @@ op 0x200013d: FadeOut
|
||||||
op 0x200013e: FadeTo
|
op 0x200013e: FadeTo
|
||||||
op 0x200013f: GetCurrentWeather
|
op 0x200013f: GetCurrentWeather
|
||||||
op 0x2000140: ChangeWeather
|
op 0x2000140: ChangeWeather
|
||||||
opcodes 0x2000141-0x3ffffff unused
|
op 0x2000145: ToggleFogOfWar (tfow)
|
||||||
|
opcodes 0x2000146-0x3ffffff unused
|
||||||
|
|
|
@ -67,6 +67,19 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpToggleFogOfWar : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getEnvironment().mWindowManager->toggleFogOfWar();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeEnableBirthMenu = 0x200000e;
|
const int opcodeEnableBirthMenu = 0x200000e;
|
||||||
const int opcodeEnableClassMenu = 0x200000f;
|
const int opcodeEnableClassMenu = 0x200000f;
|
||||||
const int opcodeEnableNameMenu = 0x2000010;
|
const int opcodeEnableNameMenu = 0x2000010;
|
||||||
|
@ -79,6 +92,7 @@ namespace MWScript
|
||||||
const int opcodeEnableRest = 0x2000017;
|
const int opcodeEnableRest = 0x2000017;
|
||||||
const int opcodeShowRestMenu = 0x2000018;
|
const int opcodeShowRestMenu = 0x2000018;
|
||||||
const int opcodeGetButtonPressed = 0x2000137;
|
const int opcodeGetButtonPressed = 0x2000137;
|
||||||
|
const int opcodeToggleFogOfWar = 0x2000145;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -100,6 +114,9 @@ namespace MWScript
|
||||||
extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu);
|
extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu);
|
||||||
|
|
||||||
extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed);
|
extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed);
|
||||||
|
|
||||||
|
extensions.registerInstruction ("togglefogofwar", "", opcodeToggleFogOfWar);
|
||||||
|
extensions.registerInstruction ("tfow", "", opcodeToggleFogOfWar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -135,6 +152,8 @@ namespace MWScript
|
||||||
new OpShowDialogue (MWGui::GM_Rest));
|
new OpShowDialogue (MWGui::GM_Rest));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed);
|
interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed);
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue