当前位置: 首页>>代码示例>>C++>>正文


C++ DirAccess::change_dir方法代码示例

本文整理汇总了C++中DirAccess::change_dir方法的典型用法代码示例。如果您正苦于以下问题:C++ DirAccess::change_dir方法的具体用法?C++ DirAccess::change_dir怎么用?C++ DirAccess::change_dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirAccess的用法示例。


在下文中一共展示了DirAccess::change_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ok_pressed

    void ok_pressed() {

        if (!_test_path())
            return;

        String dir;

        if (import_mode) {
            dir=project_path->get_text();


        } else {
            DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);

            if (d->change_dir(project_path->get_text())!=OK) {
                error->set_text("Invalid Path for Project (changed anything?)");
                memdelete(d);
                return;
            }

            dir=d->get_current_dir();
            memdelete(d);

            FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE);
            if (!f) {
                error->set_text("Couldn't create engine.cfg in project path");
            } else {

                f->store_line("; Engine configuration file.");
                f->store_line("; It's best to edit using the editor UI, not directly,");
                f->store_line("; becausethe parameters that go here are not obvious.");
                f->store_line("; ");
                f->store_line("; Format: ");
                f->store_line(";   [section] ; section goes between []");
                f->store_line(";   param=value ; assign values to parameters");
                f->store_line("\n");
                f->store_line("[application]");
                f->store_line("name=\""+project_name->get_text()+"\"");
                f->store_line("icon=\"icon.png\"");

                memdelete(f);

                ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons"));
            }



        }

        dir=dir.replace("\\","/");
        if (dir.ends_with("/"))
            dir=dir.substr(0,dir.length()-1);
        String proj=dir.replace("/","::");
        EditorSettings::get_singleton()->set("projects/"+proj,dir);
        EditorSettings::get_singleton()->save();



        hide();
        emit_signal("project_created");

    }
开发者ID:JASGames,项目名称:godot,代码行数:62,代码来源:project_manager.cpp

示例2: _path_changed

void ScriptCreateDialog::_path_changed(const String& p_path) {

    path_valid=false;
    String p =p_path;

    if (p=="")	 {

        path_error_label->set_text("Path is Empty");
        path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
        return;

    }

    p = Globals::get_singleton()->localize_path(p);
    if (!p.begins_with("res://")) {

        path_error_label->set_text("Path is not local");
        path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
        return;
    }

    if (p.find("/") || p.find("\\")) {
        DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);

        if (d->change_dir(p.get_base_dir())!=OK) {

            path_error_label->set_text("Base Path Invalid");
            path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
            memdelete(d);
            return;

        }
        memdelete(d);
    }



    FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);

    if (f->file_exists(p)) {

        path_error_label->set_text("File Exists");
        path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
        memdelete(f);
        return;
    }

    memdelete(f);

    String extension=p.extension();
    List<String> extensions;

    int l=language_menu->get_selected();
    ScriptServer::get_language( l )->get_recognized_extensions(&extensions);

    bool found=false;
    for(List<String>::Element *E=extensions.front();E;E=E->next()) {
        if (E->get().nocasecmp_to(extension)==0) {
            found=true;
            break;
        }
    }

    if (!found) {

        path_error_label->set_text("Invalid Extension");
        path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
        return;
    }


    path_error_label->set_text("Path is Valid");
    path_error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));

    path_valid=true;

}
开发者ID:BradWBeer,项目名称:godot,代码行数:77,代码来源:script_create_dialog.cpp


注:本文中的DirAccess::change_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。