From 78a6e235c3b0006bf29868d5f7ad0628d522fa79 Mon Sep 17 00:00:00 2001 From: navewindre Date: Fri, 31 Aug 2018 18:57:02 +0200 Subject: ah yes --- loader/ui.h | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 10 deletions(-) (limited to 'loader/ui.h') diff --git a/loader/ui.h b/loader/ui.h index 12cc37c..a6874f5 100644 --- a/loader/ui.h +++ b/loader/ui.h @@ -18,8 +18,41 @@ char g_login[ 32 ]; int g_game = 1; float g_progress = 0.f; +enum { + STATUS_LOGIN, + STATUS_LOGGING_IN, + STATUS_LOGGED_IN, + STATUS_LOADING, +}; + +int g_status = STATUS_LOGIN; + extern void execute_login( ); +enum { + GAME_UNSAFE = 0, + GAME_SAFE = 1, +}; + +struct game_t { + int status; + char name[ 32 ]; + bool valid_sub; +}; + + +std::vector< game_t > games = { + { GAME_SAFE, xors( "csgo" ), true }, + { GAME_UNSAFE, xors( "csgo ( beta )" ), false } +}; + + +//fill this vector when receiving game data based on the one above (this is just a test sample one) +std::vector< ui::dropdowns::dropdown_item_t< int > > game_list = { + { xors( "csgo" ), 1 }, + { xors( "csgo ( beta )" ), 2 }, +}; + namespace ui { auto menu = std::make_shared< ui::c_menu >( 0, 0, 500, 400, xors( "moneybot" ), "" ); @@ -30,22 +63,61 @@ namespace ui menu = std::make_shared< ui::c_menu >( 0, 0, 450, 375, xors( "moneybot" ), "" ); auto login_form = menu->add_item( std::make_shared< ui::c_form >( 120, 20, 190, - 0, xors( "login" ) ) ); - - login_form->add_item( std::make_shared< ui::c_text_input >( 15, 0, 140, xors( "username" ), 32, g_login ) ); - login_form->add_item( std::make_shared< ui::c_dropdown< > >( 15, 0, 140, xors( "game" ), &g_game, &dropdowns::games ) ); - login_form->add_item( std::make_shared< ui::base_item >( 0, 0, 0, 3 ) ); - login_form->add_item( std::make_shared< ui::c_button >( 15, 0, 140, 18, xors( "submit" ), [ ]( ) { - execute_login( ); - } ) ); - login_form->add_item( std::make_shared< ui::c_progress_bar >( 15, 0, 140, &g_progress ) ); - + 115, xors( "login" ) ) ); { + login_form->add_item( std::make_shared< ui::c_text_input >( 15, 0, 140, xors( "username" ), 32, g_login, true ) ); + login_form->add_item( std::make_shared< ui::base_item >( 0, 0, 0, 3 ) ); + login_form->add_item( std::make_shared< ui::c_button >( 15, 0, 140, 18, xors( "submit" ), [ ]( ) { + g_status = STATUS_LOGGING_IN; + /* + execute your code to log in here + */ + } ) ); + } + + login_form->set_cond( [ ]( ) { return g_status == STATUS_LOGIN; } ); + + auto logging_in_form = menu->add_item( std::make_shared< ui::c_form >( 120, 20, 190, 115, xors( "logging in" ) ) ); { + logging_in_form->add_item( std::make_shared< ui::c_label >( 54, 39, xors( "please wait." ) ) ); + } + + logging_in_form->set_cond( [ ]( ) { return g_status == STATUS_LOGGING_IN; } ); + + auto games_form = menu->add_item( std::make_shared< ui::c_form >( 120, 20, 190, 115, xors( "inject" ) ) ); { + games_form->add_item( std::make_shared< ui::c_dropdown< > >( 15, 0, 140, xors( "game" ), &g_game, &game_list ) ); + games_form->add_item( std::make_shared< ui::c_button >( 15, 0, 140, 18, xors( "inject" ), [ ]( ) { + g_status = STATUS_LOADING; + /* + execute your code to inject here + */ + } ) ); + + games_form->add_item( std::make_shared< ui::c_label >( 15, 0, xors( "subscription: active" ) ) )->set_cond( [ ]( ) { return games.at( g_game - 1 ).valid_sub; } ); + games_form->add_item( std::make_shared< ui::c_label >( 15, 0, xors( "subscription: inactive" ) ) )->set_cond( [ ]( ) { return !games.at( g_game - 1 ).valid_sub; } ); + games_form->add_item( std::make_shared< ui::c_label >( 15, 0, xors( "status: safe" ) ) )->set_cond( [ ]( ) { return games.at( g_game - 1 ).status == GAME_SAFE; } ); + games_form->add_item( std::make_shared< ui::c_label >( 15, 0, xors( "status: unsafe" ) ) )->set_cond( [ ]( ) { return games.at( g_game - 1 ).status == GAME_UNSAFE; } ); + } + + games_form->set_cond( [ ]( ) { return g_status == STATUS_LOGGED_IN; } ); + + auto loading_form = menu->add_item( std::make_shared< ui::c_form >( 120, 20, 190, 115, xors( "loading" ) ) ); { + loading_form->add_item( std::make_shared< ui::c_label >( 54, 39, xors( "please wait." ) ) ); + } + + loading_form->set_cond( [ ]( ) { return g_status == STATUS_LOADING; } ); + menu->add_item( std::make_shared< ui::c_button >( 393, 208, 50, 18, xors( "exit" ), [ ]( ) { exit( 0 ); } ) ); was_setup = true; } else { render_item( menu.get( ) ); + static float loading_time; + if( g_status == STATUS_LOGGING_IN && !loading_time ) { + loading_time = GetTickCount( ) * 0.001f + 2.f; + } + else if( g_status == STATUS_LOGGING_IN && GetTickCount( ) * 0.001f > loading_time ) { + g_status = STATUS_LOGGED_IN; + } } } } \ No newline at end of file -- cgit v1.2.3