After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.6 KiB |
@ -1,70 +0,0 @@
|
||||
/*
|
||||
https://github.com/peterix/dfhack
|
||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef CL_MOD_VEGETATION
|
||||
#define CL_MOD_VEGETATION
|
||||
/**
|
||||
* \defgroup grp_vegetation Vegetation : stuff that grows and gets cut down or trampled by dwarves
|
||||
* @ingroup grp_modules
|
||||
*/
|
||||
|
||||
#include "Export.h"
|
||||
#include "DataDefs.h"
|
||||
#include "df/plant.h"
|
||||
|
||||
namespace DFHack
|
||||
{
|
||||
namespace Vegetation
|
||||
{
|
||||
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
|
||||
|
||||
// "Simplified" copy of plant
|
||||
struct t_plant {
|
||||
df::language_name name;
|
||||
df::plant_flags flags;
|
||||
int16_t material;
|
||||
df::coord pos;
|
||||
int32_t grow_counter;
|
||||
uint16_t temperature_1;
|
||||
uint16_t temperature_2;
|
||||
int32_t is_burning;
|
||||
int32_t hitpoints;
|
||||
int16_t update_order;
|
||||
//std::vector<void *> unk1;
|
||||
//int32_t unk2;
|
||||
//uint16_t temperature_3;
|
||||
//uint16_t temperature_4;
|
||||
//uint16_t temperature_5;
|
||||
// Pointer to original object, in case you want to modify it
|
||||
df::plant *origin;
|
||||
};
|
||||
|
||||
DFHACK_EXPORT bool isValid();
|
||||
DFHACK_EXPORT uint32_t getCount();
|
||||
DFHACK_EXPORT df::plant * getPlant(const int32_t index);
|
||||
DFHACK_EXPORT bool copyPlant (const int32_t index, t_plant &out);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
https://github.com/peterix/dfhack
|
||||
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "Internal.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
#include "VersionInfo.h"
|
||||
#include "MemAccess.h"
|
||||
#include "Types.h"
|
||||
#include "Core.h"
|
||||
using namespace DFHack;
|
||||
|
||||
#include "modules/Vegetation.h"
|
||||
#include "df/world.h"
|
||||
|
||||
using namespace DFHack;
|
||||
using df::global::world;
|
||||
|
||||
bool Vegetation::isValid()
|
||||
{
|
||||
return (world != NULL);
|
||||
}
|
||||
|
||||
uint32_t Vegetation::getCount()
|
||||
{
|
||||
return world->plants.all.size();
|
||||
}
|
||||
|
||||
df::plant * Vegetation::getPlant(const int32_t index)
|
||||
{
|
||||
if (uint32_t(index) >= getCount())
|
||||
return NULL;
|
||||
return world->plants.all[index];
|
||||
}
|
||||
|
||||
bool Vegetation::copyPlant(const int32_t index, t_plant &out)
|
||||
{
|
||||
if (uint32_t(index) >= getCount())
|
||||
return false;
|
||||
|
||||
out.origin = world->plants.all[index];
|
||||
|
||||
out.name = out.origin->name;
|
||||
out.flags = out.origin->flags;
|
||||
out.material = out.origin->material;
|
||||
out.pos = out.origin->pos;
|
||||
out.grow_counter = out.origin->grow_counter;
|
||||
out.temperature_1 = out.origin->temperature.whole;
|
||||
out.temperature_2 = out.origin->temperature.fraction;
|
||||
out.is_burning = out.origin->is_burning;
|
||||
out.hitpoints = out.origin->hitpoints;
|
||||
out.update_order = out.origin->update_order;
|
||||
//out.unk1 = out.origin->anon_1;
|
||||
//out.unk2 = out.origin->anon_2;
|
||||
//out.temperature_3 = out.origin->temperature_unk;
|
||||
//out.temperature_4 = out.origin->min_safe_temp;
|
||||
//out.temperature_5 = out.origin->max_safe_temp;
|
||||
return true;
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
-- Read the tiles from the screen and display info about them.
|
||||
|
||||
local utils = require 'utils'
|
||||
local gui = require 'gui'
|
||||
|
||||
InspectScreen = defclass(InspectScreen, gui.Screen)
|
||||
|
||||
function InspectScreen:init(args)
|
||||
local w,h = dfhack.screen.getWindowSize()
|
||||
self.cursor_x = math.floor(w/2)
|
||||
self.cursor_y = math.floor(h/2)
|
||||
end
|
||||
|
||||
function InspectScreen:computeFrame(parent_rect)
|
||||
local sw, sh = parent_rect.width, parent_rect.height
|
||||
self.cursor_x = math.max(0, math.min(self.cursor_x, sw-1))
|
||||
self.cursor_y = math.max(0, math.min(self.cursor_y, sh-1))
|
||||
|
||||
local frame = { w = 14, r = 1, h = 10, t = 1 }
|
||||
if self.cursor_x > sw/2 then
|
||||
frame = { w = 14, l = 1, h = 10, t = 1 }
|
||||
end
|
||||
|
||||
return gui.compute_frame_body(sw, sh, frame, 1, 0, false)
|
||||
end
|
||||
|
||||
function InspectScreen:onRenderFrame(dc, rect)
|
||||
self:renderParent()
|
||||
self.cursor_pen = dfhack.screen.readTile(self.cursor_x, self.cursor_y)
|
||||
if gui.blink_visible(100) then
|
||||
dfhack.screen.paintTile({ch='X',fg=COLOR_LIGHTGREEN}, self.cursor_x, self.cursor_y)
|
||||
end
|
||||
dc:fill(rect, {ch=' ',fg=COLOR_WHITE,bg=COLOR_CYAN})
|
||||
end
|
||||
|
||||
local FG_PEN = {fg=COLOR_WHITE,bg=COLOR_BLACK,tile_color=true}
|
||||
local BG_PEN = {fg=COLOR_BLACK,bg=COLOR_WHITE,tile_color=true}
|
||||
local TXT_PEN = {fg=COLOR_WHITE}
|
||||
|
||||
function InspectScreen:onRenderBody(dc)
|
||||
dc:pen(COLOR_WHITE, COLOR_CYAN)
|
||||
if self.cursor_pen then
|
||||
local info = self.cursor_pen
|
||||
dc:string('CH: '):char(info.ch, FG_PEN):char(info.ch, BG_PEN):string(' '):string(''..info.ch,TXT_PEN):newline()
|
||||
local fgcolor = info.fg
|
||||
local fgstr = info.fg
|
||||
if info.bold then
|
||||
fgcolor = (fgcolor+8)%16
|
||||
fgstr = fgstr..'+8'
|
||||
end
|
||||
dc:string('FG: '):string('NN',{fg=fgcolor}):string(' '):string(''..fgstr,TXT_PEN)
|
||||
dc:seek(dc.width-1):char(info.ch,{fg=info.fg,bold=info.bold}):newline()
|
||||
dc:string('BG: '):string('NN',{fg=info.bg}):string(' '):string(''..info.bg,TXT_PEN)
|
||||
dc:seek(dc.width-1):char(info.ch,{fg=COLOR_BLACK,bg=info.bg}):newline()
|
||||
local bstring = 'false'
|
||||
if info.bold then bstring = 'true' end
|
||||
dc:string('Bold: '..bstring):newline():newline()
|
||||
|
||||
if info.tile and gui.USE_GRAPHICS then
|
||||
dc:string('TL: '):tile(' ', info.tile, FG_PEN):tile(' ', info.tile, BG_PEN):string(' '..info.tile):newline()
|
||||
if info.tile_color then
|
||||
dc:string('Color: true')
|
||||
elseif info.tile_fg then
|
||||
dc:string('FG: '):string('NN',{fg=info.tile_fg}):string(' '):string(''..info.tile_fg,TXT_PEN):newline()
|
||||
dc:string('BG: '):string('NN',{fg=info.tile_bg}):string(' '):string(''..info.tile_bg,TXT_PEN):newline()
|
||||
end
|
||||
end
|
||||
else
|
||||
dc:string('Invalid', COLOR_LIGHTRED)
|
||||
end
|
||||
end
|
||||
|
||||
local MOVEMENT_KEYS = {
|
||||
CURSOR_UP = { 0, -1, 0 }, CURSOR_DOWN = { 0, 1, 0 },
|
||||
CURSOR_LEFT = { -1, 0, 0 }, CURSOR_RIGHT = { 1, 0, 0 },
|
||||
CURSOR_UPLEFT = { -1, -1, 0 }, CURSOR_UPRIGHT = { 1, -1, 0 },
|
||||
CURSOR_DOWNLEFT = { -1, 1, 0 }, CURSOR_DOWNRIGHT = { 1, 1, 0 },
|
||||
CURSOR_UP_FAST = { 0, -1, 0, true }, CURSOR_DOWN_FAST = { 0, 1, 0, true },
|
||||
CURSOR_LEFT_FAST = { -1, 0, 0, true }, CURSOR_RIGHT_FAST = { 1, 0, 0, true },
|
||||
CURSOR_UPLEFT_FAST = { -1, -1, 0, true }, CURSOR_UPRIGHT_FAST = { 1, -1, 0, true },
|
||||
CURSOR_DOWNLEFT_FAST = { -1, 1, 0, true }, CURSOR_DOWNRIGHT_FAST = { 1, 1, 0, true },
|
||||
}
|
||||
|
||||
function InspectScreen:onInput(keys)
|
||||
if keys.LEAVESCREEN then
|
||||
self:dismiss()
|
||||
else
|
||||
for k,v in pairs(MOVEMENT_KEYS) do
|
||||
if keys[k] then
|
||||
local delta = 1
|
||||
if v[4] then
|
||||
delta = 10
|
||||
end
|
||||
self.cursor_x = self.cursor_x + delta*v[1]
|
||||
self.cursor_y = self.cursor_y + delta*v[2]
|
||||
self:updateLayout()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
InspectScreen{}:show()
|
@ -0,0 +1,26 @@
|
||||
-- On map load writes the current season to gamelog.txt
|
||||
|
||||
local seasons = {
|
||||
[0] = 'Spring',
|
||||
[1] = 'Summer',
|
||||
[2] = 'Autumn',
|
||||
[3] = 'Winter',
|
||||
}
|
||||
|
||||
local args = {...}
|
||||
|
||||
local function write_gamelog(msg)
|
||||
local log = io.open('gamelog.txt', 'a')
|
||||
log:write(msg.."\n")
|
||||
log:close()
|
||||
end
|
||||
|
||||
if args[1] == 'disable' then
|
||||
dfhack.onStateChange[_ENV] = nil
|
||||
else
|
||||
dfhack.onStateChange[_ENV] = function(op)
|
||||
if op == SC_WORLD_LOADED then
|
||||
write_gamelog(seasons[df.global.cur_season]..' has arrived on the calendar.')
|
||||
end
|
||||
end
|
||||
end
|