Mario Editor: formatting
This commit is contained in:
parent
58974f8a7e
commit
3bef592cb1
204
mario/editor.cpp
204
mario/editor.cpp
@ -126,8 +126,7 @@ void updateTool() {
|
||||
break;
|
||||
}
|
||||
global_vars.current_tool->setTexture(
|
||||
target_texture,
|
||||
getSourceRectByID( tool_id, g_current_world_type ) );
|
||||
target_texture, getSourceRectByID( tool_id, g_current_world_type ) );
|
||||
global_vars.current_tool->setId( tool_id );
|
||||
global_vars.current_tool->getCollisions()[0]->setId( tool_id );
|
||||
}
|
||||
@ -201,7 +200,8 @@ void updateToolSelection( int prev_index, ToolType::Value type ) {
|
||||
auto cur = cur_page * multiplier;
|
||||
size_t prev = prev_index * multiplier;
|
||||
for ( size_t i = prev;
|
||||
i < ( tool_vec->size() < prev + multiplier ? tool_vec->size() : prev + multiplier );
|
||||
i < ( tool_vec->size() < prev + multiplier ? tool_vec->size()
|
||||
: prev + multiplier );
|
||||
i++ ) {
|
||||
tool_vec->at( i )->setHidden( true );
|
||||
}
|
||||
@ -298,8 +298,11 @@ void selectLowerTool() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( global_vars.tool.index % multiplier >= static_cast<uint64_t>(multiplier/2) || global_vars.tool.index + multiplier/2 > max_index )
|
||||
if ( global_vars.tool.index % multiplier >=
|
||||
static_cast< uint64_t >( multiplier / 2 ) ||
|
||||
global_vars.tool.index + multiplier / 2 > max_index ) {
|
||||
return;
|
||||
}
|
||||
updateToolIndex( global_vars.tool.index + multiplier / 2 );
|
||||
}
|
||||
|
||||
@ -317,8 +320,10 @@ void selectUpperTool() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( global_vars.tool.index % multiplier < static_cast<uint64_t>(multiplier/2) )
|
||||
if ( global_vars.tool.index % multiplier <
|
||||
static_cast< uint64_t >( multiplier / 2 ) ) {
|
||||
return;
|
||||
}
|
||||
updateToolIndex( global_vars.tool.index - multiplier / 2 );
|
||||
}
|
||||
|
||||
@ -339,8 +344,11 @@ void selectPrevTool() {
|
||||
int subtraction = 1;
|
||||
if ( global_vars.tool.index % multiplier == 0 )
|
||||
subtraction = multiplier + 1;
|
||||
if ( global_vars.tool.index == 0 || global_vars.tool.index - subtraction > static_cast<uint64_t>(-multiplier) )
|
||||
if ( global_vars.tool.index == 0 ||
|
||||
global_vars.tool.index - subtraction >
|
||||
static_cast< uint64_t >( -multiplier ) ) {
|
||||
return;
|
||||
}
|
||||
updateToolIndex( global_vars.tool.index - subtraction );
|
||||
}
|
||||
|
||||
@ -419,7 +427,8 @@ void getMousePositionFlags( SDLPP::Scene &scene ) {
|
||||
global_vars.mouse.cur_flags = visitor.getFlags();
|
||||
global_vars.mouse.edit_box = visitor.getEditBoxIndexes();
|
||||
global_vars.mouse.tool_box = visitor.getToolBoxIndexes();
|
||||
global_vars.mouse.tool_type = static_cast<ToolType::Value>(visitor.getToolType());
|
||||
global_vars.mouse.tool_type =
|
||||
static_cast< ToolType::Value >( visitor.getToolType() );
|
||||
// if we found an edit box, move tool icon to that box
|
||||
if ( visitor.foundEditBox() ) {
|
||||
const auto &box = global_vars.mouse.edit_box;
|
||||
@ -447,32 +456,39 @@ void mouseUpAction( uint64_t flags, SDLPP::Scene &scene ) {
|
||||
if ( MouseVisitor::moveToolsLeft( flags ) &&
|
||||
global_vars.tool.cur_page_tools != 0 ) {
|
||||
global_vars.tool.cur_page_tools--;
|
||||
updateToolSelection( global_vars.tool.cur_page_tools + 1, ToolType::BLOCK );
|
||||
updateToolSelection( global_vars.tool.cur_page_tools + 1,
|
||||
ToolType::BLOCK );
|
||||
}
|
||||
if ( MouseVisitor::moveToolsRight( flags ) &&
|
||||
global_vars.tool.cur_page_tools != global_vars.tool.max_page_tools ) {
|
||||
global_vars.tool.cur_page_tools++;
|
||||
updateToolSelection( global_vars.tool.cur_page_tools - 1, ToolType::BLOCK );
|
||||
updateToolSelection( global_vars.tool.cur_page_tools - 1,
|
||||
ToolType::BLOCK );
|
||||
}
|
||||
if ( MouseVisitor::moveModsLeft( flags ) &&
|
||||
global_vars.tool.cur_page_mods != 0 ) {
|
||||
global_vars.tool.cur_page_mods--;
|
||||
updateToolSelection( global_vars.tool.cur_page_mods + 1, ToolType::MOD );
|
||||
updateToolSelection( global_vars.tool.cur_page_mods + 1,
|
||||
ToolType::MOD );
|
||||
}
|
||||
if ( MouseVisitor::moveModsRight( flags ) &&
|
||||
global_vars.tool.cur_page_mods != global_vars.tool.max_page_mods ) {
|
||||
global_vars.tool.cur_page_mods++;
|
||||
updateToolSelection( global_vars.tool.cur_page_mods - 1, ToolType::MOD );
|
||||
updateToolSelection( global_vars.tool.cur_page_mods - 1,
|
||||
ToolType::MOD );
|
||||
}
|
||||
if ( MouseVisitor::moveCharactersLeft( flags ) &&
|
||||
global_vars.tool.cur_page_characters != 0 ) {
|
||||
global_vars.tool.cur_page_characters--;
|
||||
updateToolSelection( global_vars.tool.cur_page_characters + 1, ToolType::CHARACTER );
|
||||
updateToolSelection( global_vars.tool.cur_page_characters + 1,
|
||||
ToolType::CHARACTER );
|
||||
}
|
||||
if ( MouseVisitor::moveCharactersRight( flags ) &&
|
||||
global_vars.tool.cur_page_characters != global_vars.tool.max_page_characters ) {
|
||||
global_vars.tool.cur_page_characters !=
|
||||
global_vars.tool.max_page_characters ) {
|
||||
global_vars.tool.cur_page_characters++;
|
||||
updateToolSelection( global_vars.tool.cur_page_characters - 1, ToolType::CHARACTER );
|
||||
updateToolSelection( global_vars.tool.cur_page_characters - 1,
|
||||
ToolType::CHARACTER );
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,7 +552,8 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
break;
|
||||
case VisitorType::Modifier:
|
||||
if ( tool_type == BlockRole::MARIO ) {
|
||||
std::get< MapObject::CHARACTER_TYPE >( obj ) = LandType::OVERWORLD;
|
||||
std::get< MapObject::CHARACTER_TYPE >( obj ) =
|
||||
LandType::OVERWORLD;
|
||||
std::get< MapObject::CHARACTER_ID >( obj ) = MARIO_ID;
|
||||
std::get< MapObject::MODIFIER_TYPE >( obj ) = 0;
|
||||
std::get< MapObject::MODIFIER_DATA >( obj ) = 0;
|
||||
@ -552,15 +569,18 @@ void placeTool( SDLPP::Scene &scene ) {
|
||||
// TODO BlockRole::Character
|
||||
} else {
|
||||
// TODO data
|
||||
std::get< MapObject::MODIFIER_TYPE >( obj ) = global_vars.current_tool->getId();
|
||||
std::get< MapObject::MODIFIER_TYPE >( obj ) =
|
||||
global_vars.current_tool->getId();
|
||||
std::get< MapObject::MODIFIER_DATA >( obj ) = 0;
|
||||
new_obj = createTerrainBlock(
|
||||
global_vars.current_tool->getId(), LandType::OVERWORLD,
|
||||
renderer, 1 + global_vars.mouse.edit_box.getX(),
|
||||
global_vars.mouse.edit_box.getY(), global_vars.translucent_terrain_texture, true );
|
||||
global_vars.mouse.edit_box.getY(),
|
||||
global_vars.translucent_terrain_texture, true );
|
||||
new_obj->getCollisions()[0]->setId( EDITOR_TERRAIN_ID );
|
||||
// TODO createModifierBlock
|
||||
dynamic_cast<MarioBlock*>(new_obj.get())->setTerrain(false);
|
||||
dynamic_cast< MarioBlock * >( new_obj.get() )
|
||||
->setTerrain( false );
|
||||
z_index = scene.getObjects().size() - 1;
|
||||
}
|
||||
break;
|
||||
@ -620,7 +640,8 @@ void pollEvents( SDLPP::Scene &scene ) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
size_t index = tool_box.getY() * (multiplier/2) + tool_box.getX();
|
||||
size_t index =
|
||||
tool_box.getY() * ( multiplier / 2 ) + tool_box.getX();
|
||||
if ( index < max_index ) {
|
||||
global_vars.tool.type = global_vars.mouse.tool_type;
|
||||
updateToolIndex( cur_page * multiplier + index );
|
||||
@ -648,31 +669,35 @@ void doInput( std::shared_ptr< SDLPP::Scene > scene ) {
|
||||
}
|
||||
}
|
||||
|
||||
void createGrid(double start_x, double start_y, int count_x, int count_y, std::shared_ptr<SDLPP::Scene> &scene) {
|
||||
void createGrid( double start_x, double start_y, int count_x, int count_y,
|
||||
std::shared_ptr< SDLPP::Scene > &scene ) {
|
||||
auto renderer = scene->getRendererShared();
|
||||
auto width = count_x * BLOCK_SIZE;
|
||||
auto height = count_y * BLOCK_SIZE;
|
||||
for ( int i = 0; i < count_x + 1; i++ ) {
|
||||
auto line_vertical = std::make_shared< SDLPP::LineRenderer >(
|
||||
start_x + i * BLOCK_SIZE, start_y, start_x + i * BLOCK_SIZE, start_y + height,
|
||||
renderer, "#282828" );
|
||||
start_x + i * BLOCK_SIZE, start_y, start_x + i * BLOCK_SIZE,
|
||||
start_y + height, renderer, "#282828" );
|
||||
line_vertical->setPermanent();
|
||||
line_vertical->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
scene->addObject( line_vertical );
|
||||
}
|
||||
for ( int i = 0; i < count_y + 1; i++ ) {
|
||||
auto line_horizontal = std::make_shared< SDLPP::LineRenderer >(
|
||||
start_x, start_y + i * BLOCK_SIZE,
|
||||
start_x + width, start_y + i * BLOCK_SIZE,
|
||||
renderer, "#282828" );
|
||||
start_x, start_y + i * BLOCK_SIZE, start_x + width,
|
||||
start_y + i * BLOCK_SIZE, renderer, "#282828" );
|
||||
line_horizontal->setPermanent();
|
||||
line_horizontal->setAlignment( SDLPP::OBJ_CENTER,
|
||||
SDLPP::OBJ_CENTER );
|
||||
line_horizontal->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
scene->addObject( line_horizontal );
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<std::shared_ptr<SDLPP::TextRenderer>, std::shared_ptr<SDLPP::TextRenderer>> createArrowControls(double left_x, double right_x, double start_y, double height, uint64_t left_id, uint64_t right_id, std::shared_ptr<SDLPP::Scene> &scene, std::shared_ptr<SDLPP::FontConfiguration> &font_config) {
|
||||
std::pair< std::shared_ptr< SDLPP::TextRenderer >,
|
||||
std::shared_ptr< SDLPP::TextRenderer > >
|
||||
createArrowControls(
|
||||
double left_x, double right_x, double start_y, double height,
|
||||
uint64_t left_id, uint64_t right_id, std::shared_ptr< SDLPP::Scene > &scene,
|
||||
std::shared_ptr< SDLPP::FontConfiguration > &font_config ) {
|
||||
auto renderer = scene->getRendererShared();
|
||||
// white rectangles
|
||||
auto rectangle1 = std::make_shared< SDLPP::RectangleRender >(
|
||||
@ -692,7 +717,8 @@ std::pair<std::shared_ptr<SDLPP::TextRenderer>, std::shared_ptr<SDLPP::TextRende
|
||||
scene->addObject( rectangle2 );
|
||||
|
||||
auto left = std::make_shared< SDLPP::TextRenderer >(
|
||||
left_x, start_y + height / 2.0 - 0.5 * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, renderer, "<", font_config );
|
||||
left_x, start_y + height / 2.0 - 0.5 * BLOCK_SIZE, BLOCK_SIZE,
|
||||
BLOCK_SIZE, renderer, "<", font_config );
|
||||
left->setId( 0 );
|
||||
left->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
left->setPermanent();
|
||||
@ -707,12 +733,17 @@ std::pair<std::shared_ptr<SDLPP::TextRenderer>, std::shared_ptr<SDLPP::TextRende
|
||||
return { left, right };
|
||||
}
|
||||
|
||||
void populateToolGrid(int count_x, int count_y, float start_x, float start_y, ToolType::Value type, const std::vector<uint64_t> &blocks, std::vector<std::shared_ptr<SDLPP::RenderObject>> &tool_store, std::vector<std::shared_ptr<SDLPP::RenderObject>> &tool_box_store, std::shared_ptr<SDLPP::Scene> &scene) {
|
||||
void populateToolGrid(
|
||||
int count_x, int count_y, float start_x, float start_y,
|
||||
ToolType::Value type, const std::vector< uint64_t > &blocks,
|
||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > &tool_store,
|
||||
std::vector< std::shared_ptr< SDLPP::RenderObject > > &tool_box_store,
|
||||
std::shared_ptr< SDLPP::Scene > &scene ) {
|
||||
auto renderer = scene->getRendererShared();
|
||||
for ( int j = 0; j < count_y; j++ ) {
|
||||
for ( int i = 0; i < count_x; i++ ) {
|
||||
auto tool_box = std::make_shared< ToolBox >( i, j,
|
||||
start_x, start_y, renderer, false );
|
||||
auto tool_box = std::make_shared< ToolBox >( i, j, start_x, start_y,
|
||||
renderer, false );
|
||||
scene->addObject( tool_box );
|
||||
}
|
||||
}
|
||||
@ -721,7 +752,8 @@ void populateToolGrid(int count_x, int count_y, float start_x, float start_y, To
|
||||
switch ( type ) {
|
||||
case ToolType::CHARACTER:
|
||||
if ( block == MARIO_ID )
|
||||
tool_store.push_back(createMario(LandType::OVERWORLD, renderer, 0, 0));
|
||||
tool_store.push_back(
|
||||
createMario( LandType::OVERWORLD, renderer, 0, 0 ) );
|
||||
else
|
||||
case ToolType::BLOCK:
|
||||
case ToolType::MOD:
|
||||
@ -732,16 +764,15 @@ void populateToolGrid(int count_x, int count_y, float start_x, float start_y, To
|
||||
tool_store.back()->setPermanent();
|
||||
auto x = tool_index % count_x;
|
||||
auto y = tool_index / count_x;
|
||||
tool_store.back()->setPos( start_x +
|
||||
x * BLOCK_SIZE,
|
||||
tool_store.back()->setPos( start_x + x * BLOCK_SIZE,
|
||||
start_y + y * BLOCK_SIZE );
|
||||
scene->addObject( tool_store.back() );
|
||||
tool_index = ( tool_index + 1 ) % ( 2 * count_x );
|
||||
}
|
||||
for ( int j = 0; j < count_y; j++ ) {
|
||||
for ( int i = 0; i < count_x; i++ ) {
|
||||
auto tool_box = std::make_shared< ToolBox >( i, j,
|
||||
start_x, start_y, renderer );
|
||||
auto tool_box =
|
||||
std::make_shared< ToolBox >( i, j, start_x, start_y, renderer );
|
||||
tool_box->setType( type );
|
||||
scene->addObject( tool_box );
|
||||
tool_box->setColor( "#00000000" );
|
||||
@ -750,20 +781,22 @@ void populateToolGrid(int count_x, int count_y, float start_x, float start_y, To
|
||||
}
|
||||
}
|
||||
|
||||
void checkArrowsEnabled( uint64_t cur_page, uint64_t max_page, uint64_t left_flag, uint64_t right_flag, std::shared_ptr<SDLPP::TextRenderer> &left_arrow, std::shared_ptr<SDLPP::TextRenderer> &right_arrow, std::shared_ptr<SDLPP::Font> &font, bool map = false ) {
|
||||
if ( cur_page == 0 &&
|
||||
getFlag( left_flag ) ) {
|
||||
void checkArrowsEnabled( uint64_t cur_page, uint64_t max_page,
|
||||
uint64_t left_flag, uint64_t right_flag,
|
||||
std::shared_ptr< SDLPP::TextRenderer > &left_arrow,
|
||||
std::shared_ptr< SDLPP::TextRenderer > &right_arrow,
|
||||
std::shared_ptr< SDLPP::Font > &font,
|
||||
bool map = false ) {
|
||||
if ( cur_page == 0 && getFlag( left_flag ) ) {
|
||||
setFlag( UPDATE_FLAG );
|
||||
unsetFlag( left_flag );
|
||||
left_arrow->setTextColor( font, "#CCCCCC", "#CCCCCC", 0.05 );
|
||||
} else if ( cur_page != 0 &&
|
||||
!getFlag( left_flag ) ) {
|
||||
} else if ( cur_page != 0 && !getFlag( left_flag ) ) {
|
||||
setFlag( UPDATE_FLAG );
|
||||
setFlag( left_flag );
|
||||
left_arrow->setTextColor( font, "#000000", "#282828", 0.05 );
|
||||
}
|
||||
if ( cur_page == max_page &&
|
||||
getFlag( right_flag ) ) {
|
||||
if ( cur_page == max_page && getFlag( right_flag ) ) {
|
||||
setFlag( UPDATE_FLAG );
|
||||
unsetFlag( right_flag );
|
||||
if ( map ) {
|
||||
@ -772,8 +805,7 @@ void checkArrowsEnabled( uint64_t cur_page, uint64_t max_page, uint64_t left_fla
|
||||
} else {
|
||||
right_arrow->setTextColor( font, "#CCCCCC", "#CCCCCC", 0.05 );
|
||||
}
|
||||
} else if ( cur_page != max_page &&
|
||||
!getFlag( right_flag ) ) {
|
||||
} else if ( cur_page != max_page && !getFlag( right_flag ) ) {
|
||||
setFlag( UPDATE_FLAG );
|
||||
setFlag( right_flag );
|
||||
right_arrow->setTextColor( font, "#000000", "#282828", 0.05 );
|
||||
@ -803,9 +835,8 @@ int main() {
|
||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_mario_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/mario.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture =
|
||||
std::make_shared< SDLPP::Texture >( renderer, "sprites/terrain.png",
|
||||
MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture = std::make_shared< SDLPP::Texture >(
|
||||
renderer, "sprites/terrain.png", MARIO_OVERWORLD_COLORKEY );
|
||||
g_translucent_terrain_texture->setAlpha( 100 );
|
||||
|
||||
auto scene = std::make_shared< SDLPP::Scene >( renderer );
|
||||
@ -816,7 +847,8 @@ int main() {
|
||||
scene->addObject( bg );
|
||||
|
||||
// TODO file name
|
||||
loadMap( scene, global_vars.mario, "test_binary.bin", renderer, global_vars.objects );
|
||||
loadMap( scene, global_vars.mario, "test_binary.bin", renderer,
|
||||
global_vars.objects );
|
||||
|
||||
auto font = std::make_shared< SDLPP::Font >( "testfont.ttf", 36 );
|
||||
auto font_config = std::make_shared< SDLPP::FontConfiguration >(
|
||||
@ -824,10 +856,14 @@ int main() {
|
||||
|
||||
// create grids and arrow controls
|
||||
// map
|
||||
auto arrows = createArrowControls(0, (MAP_WIDTH + 1) * BLOCK_SIZE, (MAP_WIDTH + 2 - MAP_HEIGHT) * BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE, EDITOR_LEFT_MAP_ID, EDITOR_RIGHT_MAP_ID, scene, font_config);
|
||||
auto arrows = createArrowControls(
|
||||
0, ( MAP_WIDTH + 1 ) * BLOCK_SIZE,
|
||||
( MAP_WIDTH + 2 - MAP_HEIGHT ) * BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
||||
EDITOR_LEFT_MAP_ID, EDITOR_RIGHT_MAP_ID, scene, font_config );
|
||||
auto left_map_arrow = arrows.first;
|
||||
auto right_map_arrow = arrows.second;
|
||||
createGrid(BLOCK_SIZE, 1 - MAP_HEIGHT * BLOCK_SIZE, MAP_WIDTH, MAP_HEIGHT, scene);
|
||||
createGrid( BLOCK_SIZE, 1 - MAP_HEIGHT * BLOCK_SIZE, MAP_WIDTH, MAP_HEIGHT,
|
||||
scene );
|
||||
// edit blocks on map
|
||||
for ( int i = 0; i < MAP_WIDTH; i++ ) {
|
||||
for ( int j = 0; j < MAP_HEIGHT; j++ ) {
|
||||
@ -837,30 +873,50 @@ int main() {
|
||||
}
|
||||
|
||||
// tools
|
||||
populateToolGrid(TOOLS_WIDTH, 2, (MAP_WIDTH - TOOLS_WIDTH) * BLOCK_SIZE, BLOCK_SIZE, ToolType::BLOCK, possibleBlocks, global_vars.tools, global_vars.tool_boxes, scene);
|
||||
arrows = createArrowControls((MAP_WIDTH - TOOLS_WIDTH - 1) * BLOCK_SIZE, MAP_WIDTH * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE, EDITOR_LEFT_TOOL_ID, EDITOR_RIGHT_TOOL_ID, scene, font_config);
|
||||
populateToolGrid( TOOLS_WIDTH, 2, ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE,
|
||||
BLOCK_SIZE, ToolType::BLOCK, possibleBlocks,
|
||||
global_vars.tools, global_vars.tool_boxes, scene );
|
||||
arrows = createArrowControls( ( MAP_WIDTH - TOOLS_WIDTH - 1 ) * BLOCK_SIZE,
|
||||
MAP_WIDTH * BLOCK_SIZE, BLOCK_SIZE,
|
||||
2 * BLOCK_SIZE, EDITOR_LEFT_TOOL_ID,
|
||||
EDITOR_RIGHT_TOOL_ID, scene, font_config );
|
||||
auto left_tool_arrow = arrows.first;
|
||||
auto right_tool_arrow = arrows.second;
|
||||
createGrid(( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE, BLOCK_SIZE, TOOLS_WIDTH, 2, scene);
|
||||
createGrid( ( MAP_WIDTH - TOOLS_WIDTH ) * BLOCK_SIZE, BLOCK_SIZE,
|
||||
TOOLS_WIDTH, 2, scene );
|
||||
// mods
|
||||
populateToolGrid(MOD_WIDTH, 2, 2 * BLOCK_SIZE, BLOCK_SIZE, ToolType::MOD, possibleMods, global_vars.mods, global_vars.mod_boxes, scene);
|
||||
arrows = createArrowControls(BLOCK_SIZE, (MOD_WIDTH + 2) * BLOCK_SIZE, BLOCK_SIZE, 2*BLOCK_SIZE, EDITOR_LEFT_MOD_ID, EDITOR_RIGHT_MOD_ID, scene, font_config);
|
||||
populateToolGrid( MOD_WIDTH, 2, 2 * BLOCK_SIZE, BLOCK_SIZE, ToolType::MOD,
|
||||
possibleMods, global_vars.mods, global_vars.mod_boxes,
|
||||
scene );
|
||||
arrows = createArrowControls(
|
||||
BLOCK_SIZE, ( MOD_WIDTH + 2 ) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||
EDITOR_LEFT_MOD_ID, EDITOR_RIGHT_MOD_ID, scene, font_config );
|
||||
auto left_mod_arrow = arrows.first;
|
||||
auto right_mod_arrow = arrows.second;
|
||||
createGrid( 2 * BLOCK_SIZE, BLOCK_SIZE, MOD_WIDTH, 2, scene );
|
||||
// characters
|
||||
populateToolGrid(CHARACTER_WIDTH, 2, (MOD_WIDTH+5) * BLOCK_SIZE, BLOCK_SIZE, ToolType::CHARACTER, possibleCharacters, global_vars.characters, global_vars.character_boxes, scene);
|
||||
arrows = createArrowControls((MOD_WIDTH + 4) * BLOCK_SIZE, (MOD_WIDTH + 5 + CHARACTER_WIDTH) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE, EDITOR_LEFT_CHARACTER_ID, EDITOR_RIGHT_CHARACTER_ID, scene, font_config);
|
||||
populateToolGrid( CHARACTER_WIDTH, 2, ( MOD_WIDTH + 5 ) * BLOCK_SIZE,
|
||||
BLOCK_SIZE, ToolType::CHARACTER, possibleCharacters,
|
||||
global_vars.characters, global_vars.character_boxes,
|
||||
scene );
|
||||
arrows = createArrowControls(
|
||||
( MOD_WIDTH + 4 ) * BLOCK_SIZE,
|
||||
( MOD_WIDTH + 5 + CHARACTER_WIDTH ) * BLOCK_SIZE, BLOCK_SIZE,
|
||||
2 * BLOCK_SIZE, EDITOR_LEFT_CHARACTER_ID, EDITOR_RIGHT_CHARACTER_ID,
|
||||
scene, font_config );
|
||||
auto left_char_arrow = arrows.first;
|
||||
auto right_char_arrow = arrows.second;
|
||||
createGrid((MOD_WIDTH + 5) * BLOCK_SIZE, BLOCK_SIZE, CHARACTER_WIDTH, 2, scene);
|
||||
|
||||
createGrid( ( MOD_WIDTH + 5 ) * BLOCK_SIZE, BLOCK_SIZE, CHARACTER_WIDTH, 2,
|
||||
scene );
|
||||
|
||||
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
|
||||
|
||||
global_vars.tool.max_page_tools = ( possibleBlocks.size() - 1 ) / (2*TOOLS_WIDTH);
|
||||
global_vars.tool.max_page_mods = ( possibleMods.size() - 1 ) / (2*MOD_WIDTH);
|
||||
global_vars.tool.max_page_characters = ( possibleCharacters.size() - 1 ) / (2*CHARACTER_WIDTH);
|
||||
global_vars.tool.max_page_tools =
|
||||
( possibleBlocks.size() - 1 ) / ( 2 * TOOLS_WIDTH );
|
||||
global_vars.tool.max_page_mods =
|
||||
( possibleMods.size() - 1 ) / ( 2 * MOD_WIDTH );
|
||||
global_vars.tool.max_page_characters =
|
||||
( possibleCharacters.size() - 1 ) / ( 2 * CHARACTER_WIDTH );
|
||||
|
||||
auto mouse = std::make_shared< SDLPP::RectangleRender >( 0.01, 0.01, 0, 0,
|
||||
renderer );
|
||||
@ -924,10 +980,22 @@ int main() {
|
||||
frames = 0;
|
||||
base = SDL_GetTicks();
|
||||
}
|
||||
checkArrowsEnabled(global_vars.map.cur_page, global_vars.map.max_page, MAP_LEFT_ENABLED_FLAG, MAP_RIGHT_ENABLED_FLAG, left_map_arrow, right_map_arrow, font, true);
|
||||
checkArrowsEnabled(global_vars.tool.cur_page_tools, global_vars.tool.max_page_tools, TOOL_LEFT_ENABLED_FLAG, TOOL_RIGHT_ENABLED_FLAG, left_tool_arrow, right_tool_arrow, font);
|
||||
checkArrowsEnabled(global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods, MOD_LEFT_ENABLED_FLAG, MOD_RIGHT_ENABLED_FLAG, left_mod_arrow, right_mod_arrow, font);
|
||||
checkArrowsEnabled(global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, CHARACTER_LEFT_ENABLED_FLAG, CHARACTER_RIGHT_ENABLED_FLAG, left_char_arrow, right_char_arrow, font);
|
||||
checkArrowsEnabled( global_vars.map.cur_page, global_vars.map.max_page,
|
||||
MAP_LEFT_ENABLED_FLAG, MAP_RIGHT_ENABLED_FLAG,
|
||||
left_map_arrow, right_map_arrow, font, true );
|
||||
checkArrowsEnabled( global_vars.tool.cur_page_tools,
|
||||
global_vars.tool.max_page_tools,
|
||||
TOOL_LEFT_ENABLED_FLAG, TOOL_RIGHT_ENABLED_FLAG,
|
||||
left_tool_arrow, right_tool_arrow, font );
|
||||
checkArrowsEnabled( global_vars.tool.cur_page_mods,
|
||||
global_vars.tool.max_page_mods,
|
||||
MOD_LEFT_ENABLED_FLAG, MOD_RIGHT_ENABLED_FLAG,
|
||||
left_mod_arrow, right_mod_arrow, font );
|
||||
checkArrowsEnabled( global_vars.tool.cur_page_characters,
|
||||
global_vars.tool.max_page_characters,
|
||||
CHARACTER_LEFT_ENABLED_FLAG,
|
||||
CHARACTER_RIGHT_ENABLED_FLAG, left_char_arrow,
|
||||
right_char_arrow, font );
|
||||
if ( getFlag( UPDATE_FLAG ) ) {
|
||||
scene->updateSizeAndPosition();
|
||||
unsetFlag( UPDATE_FLAG );
|
||||
|
Loading…
Reference in New Issue
Block a user