-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random terrain generation #8600
base: master
Are you sure you want to change the base?
Changes from 19 commits
d8fd07a
0ba9299
168f01a
2b26e6b
7359ad2
3260648
46a8a9b
992c645
e766d26
74b0a0f
7185ecc
82c8a1b
e021218
14e8178
9a74040
11bd876
9df56bf
3c56fdc
a7d0fc0
7a8fa85
e443648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
#include "interface_radar.h" | ||
#include "localevent.h" | ||
#include "map_format_helper.h" | ||
#include "map_generator.h" | ||
#include "map_object_info.h" | ||
#include "maps.h" | ||
#include "maps_tiles.h" | ||
|
@@ -770,6 +771,34 @@ namespace Interface | |
else if ( HotKeyPressEvent( Game::HotKeyEvent::WORLD_VIEW_WORLD ) ) { | ||
eventViewWorld(); | ||
} | ||
#if defined( WITH_DEBUG ) | ||
else if ( HotKeyPressEvent( Game::HotKeyEvent::EDITOR_RANDOM_MAP_GENERATION ) ) { | ||
fheroes2::ActionCreator action( _historyManager, _mapFormat ); | ||
|
||
Maps::Generator::Configuration rmgConfig; | ||
rmgConfig.playerCount = _playerCount; | ||
idshibanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rmgConfig.regionSizeLimit = _regionSizeLimit; | ||
idshibanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if ( Maps::Generator::generateWorld( _mapFormat, rmgConfig ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Essentially, we are generating map so would |
||
_redraw |= mapUpdateFlags; | ||
|
||
action.commit(); | ||
} | ||
else { | ||
_warningMessage.reset( _( "Not able to generate a map with given parameters." ) ); | ||
} | ||
} | ||
else if ( HotKeyPressEvent( Game::HotKeyEvent::EDITOR_RANDOM_MAP_CONFIGURATION ) ) { | ||
uint32_t newCount = _playerCount; | ||
if ( Dialog::SelectCount( "Pick player count", 2, 6, newCount ) ) { | ||
_playerCount = newCount; | ||
} | ||
newCount = _regionSizeLimit; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that region size is an understandable entity for map makers. Can we come up with something more user friendly metric? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with renaming it but can't think of more suitable name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we attach the number of regions to the number of players minus the size of water on map? I assume we don't generate water area for now which is easier. In this case we won't need this parameter. |
||
if ( Dialog::SelectCount( "Limit region size", 100, 10000, newCount ) ) { | ||
_regionSizeLimit = newCount; | ||
} | ||
} | ||
#endif | ||
// map scrolling control | ||
else if ( HotKeyPressEvent( Game::HotKeyEvent::WORLD_SCROLL_LEFT ) ) { | ||
_gameArea.SetScroll( SCROLL_LEFT ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,11 @@ namespace Interface | |
int32_t _selectedTile{ -1 }; | ||
int32_t _tileUnderCursor{ -1 }; | ||
|
||
#if defined( WITH_DEBUG ) | ||
uint32_t _playerCount = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we store Configuration object instead of these 2 members? |
||
uint32_t _regionSizeLimit = 600; | ||
#endif | ||
|
||
std::function<void( const int32_t )> _cursorUpdater; | ||
|
||
fheroes2::HistoryManager _historyManager; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2023 * | ||
* Copyright (C) 2023 - 2024 * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
|
@@ -35,4 +35,5 @@ namespace fheroes2 | |
Sprite generateTownObjectImage( const int townType, const int color, const int groundId ); | ||
|
||
int32_t getTownBasementId( const int groundType ); | ||
int32_t getMineObjectInfoId( const int resource, const int groundType ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add an empty line to differentiate 2 functions. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename these files into
random_map_generator.h|cpp
to highlight randomness. Or at leastmap_random_generator.h|cpp
if we keep the format.