Skip to content
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

More obvious hint before going to sleep (UPDATED) #38722

Merged
merged 10 commits into from
Mar 14, 2020

Conversation

Pupsi-Mupsi
Copy link
Contributor

@Pupsi-Mupsi Pupsi-Mupsi commented Mar 12, 2020

Summary

SUMMARY: Interface "Small sleep menu improvement"

Purpose of change

In a nutshell: Help players with a more obvious hint before they try to sleep.
And as @Leland suggested the default sleep-option is now NO.
This PR has improved significantly thanks to: @Shibimon and @umamaistempo

Thank you all!!!

Hope you like it.

Screenshot(s)

grafik

Final version:

grafik

grafik

@Pupsi-Mupsi Pupsi-Mupsi changed the title colorize ask for deactivation More obvious hint before going to sleep Mar 12, 2020
@Leland
Copy link
Contributor

Leland commented Mar 12, 2020

Perhaps change the default selection to No as well?

@Pupsi-Mupsi
Copy link
Contributor Author

I like the idea. Makes it even safer. Any idea where or how to implement your idea?

@Shibimon
Copy link

Add this to trying to sleep with mp3 on, i always forget to turn it off before.

@Pupsi-Mupsi
Copy link
Contributor Author

Add this to trying to sleep with mp3 on, i always forget to turn it off before.

Same here. Thank you.
Your wish is granted!

@Pupsi-Mupsi Pupsi-Mupsi changed the title More obvious hint before going to sleep More obvious hint before going to sleep (UPDATED) Mar 13, 2020

// List all active items, bionics or mutations so player can deactivate them
std::vector<std::string> active;
for( auto &it : u.inv_dump() ) {
if( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) &&
it->is_transformable() ) {
it->is_tool() ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun thing: a lit cigar is not a tool and would also not pass this test because it does not have charges, I think (just tested, got everything on fire).

Since the other day I read on reddit that someone started bionic operation (ie: anesthesia) while smoking a lit cigar and that caused them to start a fire, for this reason I think that we should also consider lit items as things to notify:

So I think we should do something like

it->has_flag( flag_LITCIG ) || ( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && it->is_tool() )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only items that have destructive effect that are not tools that I found were, besides cigarettes, non-lethal grenades (insecticide, fungicide, smoke).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking!!! Added your idea.
I'm not at home right now, so a new screenshot will have to wait til tomorrow.

The only bad thing is:
Now I have to think of a new sentence that fits the lit cigar ;-)
--> You may want to turn off:
Any suggestions?

Can't think of anything good.
-> You may want to take care of:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that "You may want to take care of:" is great. Alternativaly, something like "You may want to put out the following:" or "It might be safer to shut off the following before sleeping:"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll go with "The following may have slipped your mind:". What do you think?
BTW - Tests fail. I'll take a closer look tomorrow.

src/handle_action.cpp Outdated Show resolved Hide resolved
src/handle_action.cpp Outdated Show resolved Hide resolved
@kevingranade kevingranade merged commit 8ffbe67 into CleverRaven:master Mar 14, 2020
@Pupsi-Mupsi Pupsi-Mupsi deleted the PM-AFDM branch March 14, 2020 09:55
@akirashirosawa
Copy link
Contributor

Why is the answer “no” by default even without active bionics? Is this a bug or what?
1

@akirashirosawa
Copy link
Contributor

Maybe it's better?
11
22

diff --git a/src/handle_action.cpp b/src/handle_action.cpp
--- a/src/handle_action.cpp
+++ b/src/handle_action.cpp
@@ -900,19 +900,6 @@ static void sleep()
         u.add_msg_if_player( m_info, _( "You cannot sleep while mounted." ) );
         return;
     }
-    uilist as_m;
-    as_m.text = _( "<color_white>Are you sure you want to sleep?</color>" );
-    // (Y)es/(S)ave before sleeping/(N)o
-    as_m.entries.emplace_back( 2, true,
-                               get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'N' : 'n',
-                               _( "No." ) );
-    as_m.entries.emplace_back( 1, g->get_moves_since_last_save(),
-                               get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'S' : 's',
-                               _( "Yes, and save game before sleeping." ) );
-    as_m.entries.emplace_back( 0, true,
-                               get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y',
-                               _( "Yes." ) );
-
     // List all active items, bionics or mutations so player can deactivate them
     std::vector<std::string> active;
     for( auto &it : u.inv_dump() ) {
@@ -955,9 +942,21 @@ static void sleep()
         }
     }
 
-    // ask for deactivation
+    uilist as_m;
+    as_m.text = _( "<color_white>Are you sure you want to sleep?</color>" );
     std::stringstream data;
     if( !active.empty() ) {
+        // (N)o/(S)ave before sleeping/(Y)es
+        as_m.entries.emplace_back( 2, true,
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'N' : 'n',
+                                   _( "No." ) );
+        as_m.entries.emplace_back( 1, g->get_moves_since_last_save(),
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'S' : 's',
+                                   _( "Yes, and save game before sleeping." ) );
+        as_m.entries.emplace_back( 0, true,
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y',
+                                   _( "Yes." ) );
+        // ask for deactivation
         data << as_m.text << std::endl;
         data << _( "You may want to turn off:" ) << std::endl;
         data << " " << std::endl;
@@ -965,6 +964,17 @@ static void sleep()
             data << "<color_red>" << a << "</color>" << std::endl;
         }
         as_m.text = data.str();
+    } else {
+         // (Y)es/(S)ave before sleeping/(N)o
+        as_m.entries.emplace_back( 0, true,
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y',
+                                   _( "Yes." ) );
+        as_m.entries.emplace_back( 1, g->get_moves_since_last_save(),
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'S' : 's',
+                                   _( "Yes, and save game before sleeping." ) );
+        as_m.entries.emplace_back( 2, true,
+                                   get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'N' : 'n',
+                                   _( "No." ) );
     }
 
     /* Calculate key and window variables, generate window,

@Pupsi-Mupsi
Copy link
Contributor Author

You are right. thank you. You wanne PR it yourself?

@Pupsi-Mupsi
Copy link
Contributor Author

if( !active.empty() ) { // (Y)es/(S)ave before sleeping/(N)o as_m.entries.emplace_back( 2, true, get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', _( "No." ) ); as_m.entries.emplace_back( 1, g->get_moves_since_last_save(), get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'S' : 's', _( "Yes, and save game before sleeping." ) ); as_m.entries.emplace_back( 0, true, get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y', _( "Yes." ) ); } else if( active.empty() ) { as_m.entries.emplace_back( 0, true, get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y', _( "Yes." ) ); as_m.entries.emplace_back( 1, g->get_moves_since_last_save(), get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'S' : 's', _( "Yes, and save game before sleeping." ) ); as_m.entries.emplace_back( 2, true, get_option<bool>( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', _( "No." ) ); }

I was thinking of...

@akirashirosawa
Copy link
Contributor

akirashirosawa commented Mar 14, 2020

You wanne PR it yourself?

I have not created and configured fork. It would be nice if you made changes 🙂

@Pupsi-Mupsi
Copy link
Contributor Author

You wanne PR it yourself?
I have not created and configured fork. It would be nice if you made changes 🙂

Of course!
BTW: I was thinking about changing the sentence.
"You may want to turn off:" does not fit as good after cigars and such could now also be part of the list.

An idea?

Maybe:
"The following may have slipped your mind:"
or
"You may want to take care of:"

@akirashirosawa
Copy link
Contributor

if( !active.empty() )
else if( active.empty() )

unnecessary second check

"You may want to take care of:"

That sounds good. But English is not my native)

@Pupsi-Mupsi
Copy link
Contributor Author

Thank you!
Take a look #38768.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants