-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Enable mouse input for uilist #41272
Changes from all commits
70e6421
c992213
cb1274c
6ccdd8a
b912bd4
8078efb
100e60b
3206b68
3815ec1
04e8f80
81d034b
16b5e56
e0533c2
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
#include "pimpl.h" | ||
#include "point.h" | ||
#include "string_formatter.h" | ||
#include "input.h" | ||
|
||
class translation; | ||
|
||
|
@@ -49,6 +50,23 @@ struct mvwzstr { | |
int sym = 0; | ||
}; | ||
|
||
struct entry_drawn_info { | ||
int text_x_start; | ||
int text_x_end; | ||
int y; | ||
bool include_point( point p ) const { | ||
if( text_x_start <= p.x && | ||
p.x <= text_x_end && | ||
y == p.y ) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; | ||
|
||
struct uilist_entry_drawn_info : entry_drawn_info { | ||
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. Same for this inheritance. 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. because the way of drawing for those two kinds of UI thing are not exactly the same, currently the drawn info records are not necessary to to be variant yet, but maybe in future one of them is to be changed. |
||
}; | ||
|
||
/** | ||
* uilist_entry: entry line for uilist | ||
*/ | ||
|
@@ -96,6 +114,8 @@ struct uilist_entry { | |
uilist_entry( Enum e, Args && ... args ) : | ||
uilist_entry( static_cast<int>( e ), std::forward<Args>( args )... ) | ||
{} | ||
|
||
uilist_entry_drawn_info drawn_info; | ||
}; | ||
|
||
/** | ||
|
@@ -338,6 +358,8 @@ class uilist // NOLINT(cata-xy) | |
|
||
bool started = false; | ||
|
||
uilist_entry *find_entry_by_coordinate( point p ); | ||
|
||
public: | ||
// Results | ||
// TODO change to getters | ||
|
@@ -346,6 +368,7 @@ class uilist // NOLINT(cata-xy) | |
int keypress = 0; | ||
|
||
int selected = 0; | ||
|
||
}; | ||
|
||
/** | ||
|
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.
Why not use
entry_drawn_info
directly? This inheritance does not add anything to the parent class.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.
in future there may be something added
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.
You can always create a new class in the future, but now it does nothing and only clutters up the code. And even if something is to be added in the future, I would recommend adding it to the parent class (any maybe guard it with a flag), so other UIs can also use the new functionality when they need to.
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 mean there are a lot of variant UI things in game, else than inventory and uilist, there are pickup, inventory_item_menu, crafting, and whatever, each of them are having different kind of drawing, its just this two drawn info structs are currently not different.
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.
besides, I am also considering to add some new things, such as button.
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.
And I'm pretty sure it's a bad thing we'd like to get rid of and have a unified system to display menu stuff instead.