void FWidgetBlueprintEditor::RegisterApplicationModes(const TArray<UBlueprint*>& InBlueprints, bool bShouldOpenInDefaultsMode, bool bNewlyCreated/* = false*/) { //FBlueprintEditor::RegisterApplicationModes(InBlueprints, bShouldOpenInDefaultsMode); if ( InBlueprints.Num() == 1 ) { TSharedPtr<FWidgetBlueprintEditor> ThisPtr(SharedThis(this)); // Create the modes and activate one (which will populate with a real layout) TArray< TSharedRef<FApplicationMode> > TempModeList; TempModeList.Add(MakeShareable(new FWidgetDesignerApplicationMode(ThisPtr))); TempModeList.Add(MakeShareable(new FWidgetGraphApplicationMode(ThisPtr))); for ( TSharedRef<FApplicationMode>& AppMode : TempModeList ) { AddApplicationMode(AppMode->GetModeName(), AppMode); } SetCurrentMode(FWidgetBlueprintApplicationModes::DesignerMode); } else { //// We either have no blueprints or many, open in the defaults mode for multi-editing //AddApplicationMode( // FBlueprintEditorApplicationModes::BlueprintDefaultsMode, // MakeShareable(new FBlueprintDefaultsApplicationMode(SharedThis(this)))); //SetCurrentMode(FBlueprintEditorApplicationModes::BlueprintDefaultsMode); } }
HRESULT hsGDirect3DTnLEnumerate::D3DEnum_SelectDefaultMode(int width, int height, int depth) { hsAssert(GetCurrentDriver() && GetCurrentDevice(), "Must have selected device already"); BOOL windowed = false; if (depth == 0) { // Legacy code writes out 0 bit depth to mean windowed windowed = true; depth = 32; } D3DEnum_DeviceInfo* device = GetCurrentDevice(); int i; for( i = 0; i < device->fModes.GetCount(); i++ ) { D3DEnum_ModeInfo* mode = &device->fModes[i]; if (mode->fWindowed != windowed) continue; if( depth ) { if( width < mode->fDDmode.Width ) continue; if( height < mode->fDDmode.Height ) continue; } if( depth < mode->fBitDepth ) continue; if( GetCurrentMode() ) { D3DEnum_ModeInfo* curMode = GetCurrentDriver()->fCurrentMode; if( depth ) { if( curMode->fDDmode.Width > mode->fDDmode.Width ) continue; if( curMode->fDDmode.Height > mode->fDDmode.Height ) continue; } if( curMode->fBitDepth > mode->fBitDepth ) continue; } SetCurrentMode(mode); } return S_OK; }
void FSkeletonEditor::InitSkeletonEditor(const EToolkitMode::Type Mode, const TSharedPtr<IToolkitHost>& InitToolkitHost, USkeleton* InSkeleton) { Skeleton = InSkeleton; FPersonaModule& PersonaModule = FModuleManager::LoadModuleChecked<FPersonaModule>("Persona"); PersonaToolkit = PersonaModule.CreatePersonaToolkit(InSkeleton); PersonaToolkit->GetPreviewScene()->SetDefaultAnimationMode(EPreviewSceneDefaultAnimationMode::ReferencePose); TSharedRef<IAssetFamily> AssetFamily = PersonaModule.CreatePersonaAssetFamily(InSkeleton); AssetFamily->RecordAssetOpened(FAssetData(InSkeleton)); FSkeletonTreeArgs SkeletonTreeArgs(OnPostUndo); SkeletonTreeArgs.OnObjectSelected = FOnObjectSelected::CreateSP(this, &FSkeletonEditor::HandleObjectSelected); SkeletonTreeArgs.PreviewScene = PersonaToolkit->GetPreviewScene(); ISkeletonEditorModule& SkeletonEditorModule = FModuleManager::GetModuleChecked<ISkeletonEditorModule>("SkeletonEditor"); SkeletonTree = SkeletonEditorModule.CreateSkeletonTree(PersonaToolkit->GetSkeleton(), PersonaToolkit->GetMesh(), SkeletonTreeArgs); const bool bCreateDefaultStandaloneMenu = true; const bool bCreateDefaultToolbar = true; const TSharedRef<FTabManager::FLayout> DummyLayout = FTabManager::NewLayout("NullLayout")->AddArea(FTabManager::NewPrimaryArea()); FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, SkeletonEditorAppIdentifier, DummyLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, InSkeleton); BindCommands(); AddApplicationMode( SkeletonEditorModes::SkeletonEditorMode, MakeShareable(new FSkeletonEditorMode(SharedThis(this), SkeletonTree.ToSharedRef()))); SetCurrentMode(SkeletonEditorModes::SkeletonEditorMode); // set up our editor mode check(AssetEditorModeManager); AssetEditorModeManager->SetDefaultMode(FPersonaEditModes::SkeletonSelection); ExtendMenu(); ExtendToolbar(); RegenerateMenusAndToolbars(); }
void FScriptBlueprintEditor::InitScriptBlueprintEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, const TArray<UBlueprint*>& InBlueprints, bool bShouldOpenInDefaultsMode) { InitBlueprintEditor(Mode, InitToolkitHost, InBlueprints, bShouldOpenInDefaultsMode); SetCurrentMode(FBlueprintEditorApplicationModes::BlueprintDefaultsMode); }
int main(int argc, char* argv[]) { struct filter filter; filter.include_all = false; filter.include_supported = true; filter.include_unsupported = false; filter.include_text = true; filter.include_graphics = true; // TODO: HACK: The kernel log printing requires either text mode or 32-bit // graphics. For now, just filter away anything but 32-bit graphics. filter.minbpp = 32; filter.maxbpp = 32; filter.minxres = 0; filter.maxxres = SIZE_MAX; filter.minyres = 0; filter.maxyres = SIZE_MAX; filter.minxchars = 0; filter.maxxchars = SIZE_MAX; filter.minychars = 0; filter.maxychars = SIZE_MAX; const char* argv0 = argv[0]; for ( int i = 1; i < argc; i++ ) { const char* arg = argv[i]; if ( arg[0] != '-' || !arg[1] ) break; // Intentionally not continue. argv[i] = NULL; if ( !strcmp(arg, "--") ) break; if ( arg[1] != '-' ) { char c; while ( (c = *++arg) ) switch ( c ) { default: fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); help(stderr, argv0); exit(1); } } else if ( !strcmp(arg, "--help") ) help(stdout, argv0), exit(0); else if ( !strcmp(arg, "--version") ) version(stdout, argv0), exit(0); else if ( BOOL_PARAMETER("show-all", &filter.include_all) ) { } else if ( BOOL_PARAMETER("show-supported", &filter.include_supported) ) { } else if ( BOOL_PARAMETER("show-unsupported", &filter.include_unsupported) ) { } else if ( BOOL_PARAMETER("show-text", &filter.include_text) ) { } else if ( BOOL_PARAMETER("show-graphics", &filter.include_graphics) ) { } else if ( MINMAX_PARAMETER("bpp", &filter.minbpp, &filter.maxbpp) ) { } else if ( MINMAX_PARAMETER("width", &filter.minxres, &filter.maxxres) ) { } else if ( MINMAX_PARAMETER("height", &filter.minyres, &filter.maxyres) ) { } else { fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); help(stderr, argv0); exit(1); } } compact_arguments(&argc, &argv); size_t num_modes = 0; struct dispmsg_crtc_mode* modes = GetAvailableModes(&num_modes); if ( !modes ) error(1, errno, "Unable to detect available video modes"); if ( !num_modes ) { fprintf(stderr, "No video modes are currently available.\n"); fprintf(stderr, "Try make sure a device driver exists and is activated.\n"); exit(11); } filter_modes(modes, &num_modes, &filter); if ( !num_modes ) { fprintf(stderr, "No video mode remains after filtering away unwanted modes.\n"); fprintf(stderr, "Try make sure the desired device driver is loaded and is configured correctly.\n"); exit(12); } int num_modes_display_length = 1; for ( size_t i = num_modes; 10 <= i; i /= 10 ) num_modes_display_length++; int mode_set_error = 0; size_t selection; bool decided; bool first_render; struct wincurpos render_at; retry_pick_mode: selection = 0; decided = false; first_render = true; memset(&render_at, 0, sizeof(render_at)); while ( !decided ) { fflush(stdout); struct winsize ws; if ( tcgetwinsize(1, &ws) != 0 ) { ws.ws_col = 80; ws.ws_row = 25; } struct wincurpos wcp; if ( tcgetwincurpos(1, &wcp) != 0 ) { wcp.wcp_col = 1; wcp.wcp_row = 1; } size_t off = 1; // The "Please select ..." line at the top. if ( mode_set_error ) off++; size_t entries_per_page = ws.ws_row - off; size_t page = selection / entries_per_page; size_t from = page * entries_per_page; size_t how_many_available = num_modes - from; size_t how_many = entries_per_page; if ( how_many_available < how_many ) how_many = how_many_available; size_t lines_on_screen = off + how_many; if ( first_render ) { while ( wcp.wcp_row && ws.ws_row - (wcp.wcp_row + 1) < lines_on_screen ) { printf("\e[S"); printf("\e[%juH", 1 + (uintmax_t) wcp.wcp_row); wcp.wcp_row--; wcp.wcp_col = 1; } render_at = wcp; first_render = false; } printf("\e[m"); printf("\e[%juH", 1 + (uintmax_t) render_at.wcp_row); printf("\e[2K"); if ( mode_set_error ) printf("Error: Could not set desired mode: %s\n", strerror(mode_set_error)); printf("Please select one of these video modes or press ESC to abort.\n"); for ( size_t i = 0; i < how_many; i++ ) { size_t index = from + i; size_t screenline = off + index - from; const char* color = index == selection ? "\e[31m" : "\e[m"; printf("\e[%zuH", 1 + render_at.wcp_row + screenline); printf("%s", color); printf("\e[2K"); printf(" [%-*zu] ", num_modes_display_length, index); if ( modes[i].control & DISPMSG_CONTROL_VALID ) printf("%u x %u x %u", modes[i].fb_format, modes[i].view_xres, modes[i].view_yres); else if ( modes[i].control & DISPMSG_CONTROL_OTHER_RESOLUTIONS ) printf("(enter a custom resolution)"); else printf("(unknown video device feature)"); printf("\e[m"); } printf("\e[J"); fflush(stdout); unsigned int oldtermmode; if ( gettermmode(0, &oldtermmode) < 0 ) error(1, errno, "gettermmode"); if ( settermmode(0, TERMMODE_KBKEY | TERMMODE_UNICODE | TERMMODE_SIGNAL) < 0 ) error(1, errno, "settermmode"); bool redraw = false; while ( !redraw && !decided ) { uint32_t codepoint; ssize_t numbytes = read(0, &codepoint, sizeof(codepoint)); if ( numbytes < 0 ) error(1, errno, "read"); int kbkey = KBKEY_DECODE(codepoint); if ( kbkey ) { switch ( kbkey ) { case KBKEY_ESC: if ( settermmode(0, oldtermmode) < 0 ) error(1, errno, "settermmode"); printf("\n"); exit(10); break; case KBKEY_UP: if ( selection ) selection--; else selection = num_modes -1; redraw = true; break; case KBKEY_DOWN: if ( selection + 1 == num_modes ) selection = 0; else selection++; redraw = true; break; case KBKEY_ENTER: if ( settermmode(0, oldtermmode) < 0 ) error(1, errno, "settermmode"); fgetc(stdin); printf("\n"); decided = true; break; } } else { if ( L'0' <= codepoint && codepoint <= '9' ) { uint32_t requested = codepoint - '0'; if ( requested < num_modes ) { selection = requested; redraw = true; } } } } if ( settermmode(0, oldtermmode) < 0 ) error(1, errno, "settermmode"); } struct dispmsg_crtc_mode mode = modes[selection]; if ( mode.control & DISPMSG_CONTROL_OTHER_RESOLUTIONS ) { uintmax_t req_bpp; uintmax_t req_width; uintmax_t req_height; while ( true ) { printf("Enter video mode [BPP x WIDTH x HEIGHT]: "); fflush(stdout); if ( scanf("%ju x %ju x %ju", &req_bpp, &req_width, &req_height) != 3 ) { fgetc(stdin); fflush(stdin); continue; } fgetc(stdin); break; } mode.fb_format = req_bpp; mode.view_xres = req_width; mode.view_yres = req_height; mode.control &= ~DISPMSG_CONTROL_OTHER_RESOLUTIONS; mode.control |= DISPMSG_CONTROL_VALID; } if ( !SetCurrentMode(mode) ) { error(0, mode_set_error = errno, "Unable to set video mode %ju x %ju x %ju", (uintmax_t) mode.fb_format, (uintmax_t) mode.view_xres, (uintmax_t) mode.view_yres); goto retry_pick_mode; } if ( 1 < argc ) { execvp(argv[1], argv + 1); error(127, errno, "`%s'", argv[1]); } return 0; }