Ejemplo n.º 1
0
std::string CFileDialog::AskPassword(LIBSU::CLibSU &suhandler)
{
    std::string ret;
    
    while (true)
    {
        ret = InputBox(GetTranslation("Your account doesn't have permissions to "
                "create the directory.\nTo create it with the root "
                "(administrator) account, please enter it's password below."), "", 0, '*');

        if (ret.empty())
            break;

        if (!suhandler.TestSU(ret.c_str()))
        {
            if (suhandler.GetError() == LIBSU::CLibSU::SU_ERROR_INCORRECTPASS)
                WarningBox(GetTranslation("Incorrect password given for root user\nPlease retype"));
            else
            {
                WarningBox(GetTranslation("Could not use su to gain root access.\n"
                                          "Make sure you can use su (adding the current user to the wheel group may help)."));
                break;
            }
        }
        else
            break;
    }
    
    return ret;
}
Ejemplo n.º 2
0
void CInstaller::InitButtonSection(GtkWidget *parentbox)
{
    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
    
    GtkWidget *buttonbox = gtk_hbutton_box_new();
    
    m_pCancelLabel = gtk_label_new(GetTranslation("Cancel"));
    m_pCancelButton = CreateButton(m_pCancelLabel, GTK_STOCK_CANCEL);
    g_signal_connect(G_OBJECT(m_pCancelButton), "clicked", G_CALLBACK(CancelCB), this);
    gtk_box_pack_start(GTK_BOX(buttonbox), m_pCancelButton, FALSE, FALSE, 5);
    
    gtk_box_pack_start(GTK_BOX(hbox), buttonbox, FALSE, FALSE, 5);
    
    buttonbox = gtk_hbutton_box_new();
    gtk_box_set_spacing(GTK_BOX(buttonbox), 15);
    
    m_pBackLabel = gtk_label_new(GetTranslation("Back"));
    m_pBackButton = CreateButton(m_pBackLabel, GTK_STOCK_GO_BACK);
    g_signal_connect(G_OBJECT(m_pBackButton), "clicked", G_CALLBACK(BackCB), this);
    gtk_box_pack_end(GTK_BOX(buttonbox), m_pBackButton, FALSE, FALSE, 5);

    m_pNextLabel = gtk_label_new(GetTranslation("Next"));
    m_pNextButton = CreateButton(m_pNextLabel, GTK_STOCK_GO_FORWARD);
    g_signal_connect(G_OBJECT(m_pNextButton), "clicked", G_CALLBACK(NextCB), this);
    gtk_box_pack_end(GTK_BOX(buttonbox), m_pNextButton, FALSE, FALSE, 5);

    gtk_box_pack_end(GTK_BOX(hbox), buttonbox, FALSE, FALSE, 5);
    
    gtk_box_pack_start(GTK_BOX(parentbox), hbox, FALSE, FALSE, GetMainSpacing());
}
Ejemplo n.º 3
0
void CLuaCFGMenu::ShowChoiceMenu()
{
    SEntry *entry = GetCurEntry();
    std::string item = m_pMenu->Value();
    NNCurses::TColorPair fc(COLOR_GREEN, COLOR_BLUE), dfc(COLOR_WHITE, COLOR_BLUE);
    const char *msg = CreateText(GetTranslation("Please choose a new value for %s"), GetTranslation(item.c_str()));
    NNCurses::CDialog *dialog = NNCurses::CreateBaseDialog(fc, dfc, 20, 0, msg);
    
    NNCurses::CMenu *menu = new NNCurses::CMenu(15, 8);
    
    for (TOptionsType::const_iterator it=entry->options.begin(); it!=entry->options.end(); it++)
        menu->AddEntry(*it, GetTranslation(*it));
    
    if (!entry->val.empty())
        menu->Select(entry->val);
    
    dialog->AddWidget(menu);
    
    dialog->AddButton(new NNCurses::CButton(GetTranslation("OK")), true, false);
    
    NNCurses::CButton *cancelbutton = new NNCurses::CButton(GetTranslation("Cancel"));
    dialog->AddButton(cancelbutton, true, false);
    
    NNCurses::TUI.AddGroup(dialog, true);
    
    while (dialog->Run())
        ;
    
    if (dialog->ActivatedWidget() != cancelbutton)
        entry->val = menu->Value();
    
    delete dialog;
}
Ejemplo n.º 4
0
void CParasite::Retreat(CStateManager& mgr, EStateMsg msg, float) {
  switch (msg) {
  case EStateMsg::Activate: {
    zeus::CVector3f dir = mgr.GetPlayer().GetTranslation() - GetTranslation();
    dir.z() = 0.f;
    if (dir.canBeNormalized())
      dir.normalize();
    else
      dir = mgr.GetPlayer().GetTransform().basis[1];
    x5f8_targetPos = GetTranslation() - dir * 3.f;
    FaceTarget(x5f8_targetPos);
    x5e8_stateProgress = 0;
    x742_27_landed = false;
    x742_28_onGround = false;
    x742_25_jumpVelDirty = true;
    x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_targetPos, pas::EJumpType::One));
    break;
  }
  case EStateMsg::Update:
    x3b4_speed = 1.f;
    break;
  case EStateMsg::Deactivate:
    x742_28_onGround = true;
    break;
  }
}
Ejemplo n.º 5
0
void CInstaller::CoreUpdateLanguage()
{
    CBaseInstall::CoreUpdateLanguage();
    m_pCancelButton->SetText(GetTranslation("Cancel"));
    m_pPrevButton->SetText(GetTranslation("Back"));
    UpdateButtons();
}
Ejemplo n.º 6
0
const char *CFLTKDirDialog::AskPassword(CSuTerm *suterm)
{
    const char *ret = NULL;

    while (true)
    {
        ret = fl_password(GetTranslation("Your account doesn't have permissions to "
                                         "create the directory.\nTo create it with the root "
                                         "(administrator) account, please enter the administrative password below."));

        if (!ret || !ret[0])
            break;

        try
        {
            if (!suterm->TestPassword(ret))
                fl_alert(GetTranslation("Incorrect password given, please retype."));
            else
                break;
        }
        catch (Exceptions::CExIO &e)
        {
            fl_alert(e.what());
            break;
        }
    }

    return ret;
}
Ejemplo n.º 7
0
const char *CFLTKDirDialog::AskPassword(LIBSU::CLibSU &suhandler)
{
    const char *ret = NULL;
    
    while (true)
    {
        ret = fl_password(GetTranslation("Your account doesn't have permissions to "
                "create the directory.\nTo create it with the root "
                "(administrator) account, please enter it's password below."));

        if (!ret || !ret[0])
            break;

        if (!suhandler.TestSU(ret))
        {
            if (suhandler.GetError() == LIBSU::CLibSU::SU_ERROR_INCORRECTPASS)
                fl_alert(GetTranslation("Incorrect password given for root user\nPlease retype"));
            else
            {
                fl_alert(GetTranslation("Could not use su to gain root access.\n"
                        "Make sure you can use su (adding the current user to the wheel group may help)."));
                break;
            }
        }
        else
            break;
    }
    
    return ret;
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
    if (!MainInit(argc, argv))
    {
        printf("Error: %s\n", GetTranslation("Init failed, aborting"));
        return 1;
    }
    
    // Init
    if (!(MainWin = initscr())) throwerror(false, "Could not init ncurses");
    if (!(CDKScreen = initCDKScreen(MainWin))) throwerror(false, "Could not init CDK");
    initCDKColor();

    if ((InstallInfo.dest_dir_type == DEST_DEFAULT) && !ReadAccess(InstallInfo.dest_dir))
        throwerror(true, CreateText("This installer will install files to the following directory:\n%s\n"
                                    "However you don't have read permissions to this directory\n"
                                    "Please restart the installer as a user who does or as the root user",
                                    InstallInfo.dest_dir.c_str()));
    
    int i=0;
    while(Functions[i])
    {
        if (Functions[i]()) i++;
        else
        {
            if (YesNoBox(GetTranslation("This will abort the installation\nAre you sure?")))
                break;
        }
    }

    EndProg();
    return 0;
}
Ejemplo n.º 9
0
bool ShowWelcome()
{
    char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("Welcome"));
    char filename[] = "config/welcome";
    char *buttons[2] = { GetTranslation("OK"), GetTranslation("Cancel") };
    int ret = ViewFile(filename, buttons, 2, title);
    return (ret==NO_FILE || ret==0);
}
Ejemplo n.º 10
0
bool ShowLicense()
{
    char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("License agreement"));
    char filename[] = "config/license";
    char *buttons[2] = { GetTranslation("Agree"), GetTranslation("Decline") };
    
    int ret = ViewFile(filename, buttons, 2, title);
    return (ret==NO_FILE || ret==0);
}
Ejemplo n.º 11
0
bool CLuaCFGMenu::CoreHandleEvent(NNCurses::CWidget *emitter, int event)
{
    if (CLuaWidget::CoreHandleEvent(emitter, event))
        return true;
    
    if (m_pMenu->Empty())
        return false;

    if (emitter == m_pMenu)
    {
        if (event == EVENT_DATACHANGED)
        {
            UpdateDesc();
            return true;
        }
        else if (event == EVENT_CALLBACK)
        {
            SEntry *entry = GetCurEntry();
            std::string item = m_pMenu->Value();
    
            if (entry)
            {
                switch (entry->type)
                {
                    case TYPE_STRING:
                    {
                        std::string ret = NNCurses::InputBox(CreateText(GetTranslation("Please enter a new value for %s"),
                                                             GetTranslation(item.c_str())), entry->val);
                        if (!ret.empty())
                            entry->val = ret;
                        break;
                    }
                    case TYPE_DIR:
                    {
                        std::string ret = NNCurses::DirectoryBox(CreateText(GetTranslation("Please choose a new value for %s"),
                                                             GetTranslation(item.c_str())), entry->val);
                        if (!ret.empty())
                            entry->val = ret;
                        break;
                    }
                    case TYPE_LIST:
                    case TYPE_BOOL:
                        ShowChoiceMenu();
                        break;
                }
                
                LuaDataChanged();
                return true;
            }
        }
    }
    
    return false;
}
Ejemplo n.º 12
0
tvector3 CGizmoTransformMove::RayTrace(tvector3& rayOrigin, tvector3& rayDir, tvector3& norm)
{
    tvector3 df,inters;
    m_plan=vector4(GetTranslation(), norm);
    m_plan.RayInter(inters,rayOrigin,rayDir);
    ptd = inters;
    df = inters - GetTranslation();
    df /=GetScreenFactor();
    m_LockVertex = inters;
    return df;
}
void CLuaRadioButton::AddButton(const std::string &label, TSTLVecSize n)
{
    const TSTLVecSize size = GetOptions().size();
    if (n >= size)
        m_pRadioButton->AddChoice(GetTranslation(label));
    else
        m_pRadioButton->InsertChoice(GetTranslation(label), n);
        
    if (size == 1)
        m_pRadioButton->Select(0);
}
Ejemplo n.º 14
0
bool CInstaller::AskQuit()
{
    const char *msg;
    if (Installing())
        msg = GetTranslation("Install commands are still running\n"
        "If you abort now this may lead to a broken installation\n"
        "Are you sure?");
    else
        msg = GetTranslation("This will abort the installation\nAre you sure?");
    
    return YesNoBox(msg);
}
Ejemplo n.º 15
0
CFileDialog::CFileDialog(const std::string &msg, const std::string &start) : m_bCancelled(true)
{
    m_Directory = (start.empty()) ? "/" : GetFirstValidDir(start);
    
    StartPack((m_pLabel = new CLabel(msg)), true, true, 1, 1);
    StartPack(m_pFileMenu = new CMenu(25, 8), true, true, 0, 0);
    StartPack((m_pInputField = new CInputField(m_Directory, CInputField::STRING, 1024)), false, false, 1, 0);
    AddButton(m_pOKButton = new CButton(GetTranslation("Open directory")), true, false);
    AddButton(m_pCancelButton = new CButton(GetTranslation("Cancel")), true, false);
    
    OpenDir(m_Directory);
}
Ejemplo n.º 16
0
bool FinishInstall()
{
    char *file = CreateText("%s/config/finish", InstallInfo.own_dir.c_str());
    if (FileExists(file))
    {
        char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("Please read the following text"));
        char *buttons[1] = { GetTranslation("OK") };
        ViewFile(file, buttons, 1, title);
        return true;
    }
    
    return true;
}
Ejemplo n.º 17
0
void CInstaller::CoreUpdateLanguage()
{
    CBaseInstall::CoreUpdateLanguage();
    
    SetAboutLabel();
    
    gtk_label_set(GTK_LABEL(m_pCancelLabel), GetTranslation("Cancel"));
    gtk_label_set(GTK_LABEL(m_pBackLabel), GetTranslation("Back"));
    UpdateButtons(); // Sets Next label

    if (!m_CurTitle.empty())
        SetTitle(m_CurTitle);
}
Ejemplo n.º 18
0
void CInstaller::AskQuit()
{
    const char *msg;
    if (Installing())
        msg = GetTranslation("Install commands are still running\n"
                "If you abort now this may lead to a broken installation\n"
                "Are you sure?");
    else
        msg = GetTranslation("This will abort the installation\nAre you sure?");
    
    if (NNCurses::YesNoBox(msg))
        throw Exceptions::CExUser();
}
Ejemplo n.º 19
0
void CInstaller::CoreUpdateLanguage(void)
{
    CBaseInstall::CoreUpdateLanguage();
    CFLTKBase::CoreUpdateLanguage();

    CInstallScreen *screen = GetScreen(m_pWizard->value());
    if (screen)
        SetTitle(GetTranslation(screen->GetTitle()));
    
    m_pAboutBox->label(GetTranslation("About"));
    m_pCancelButton->label(GetTranslation("Cancel"));
    m_pBackButton->label(CreateText("@<-    %s", GetTranslation("Back")));
    m_pNextButton->label(CreateText("%s    @->", GetTranslation("Next")));
}
Ejemplo n.º 20
0
void CInstaller::UpdateButtons(void)
{
    CInstallScreen *curscreen = GetScreen(m_pWizard->value());
    
    if (FirstValidScreen() && !curscreen->HasPrevWidgets())
        m_pBackButton->deactivate();
    else if (!m_bPrevButtonLocked)
        m_pBackButton->activate();
    
    if (LastValidScreen() && !curscreen->HasNextWidgets())
        m_pNextButton->label(CreateText("%s    @->|", GetTranslation("Finish")));
    else
        m_pNextButton->label(CreateText("%s    @->", GetTranslation("Next")));
}
Ejemplo n.º 21
0
void CLuaWidget::CoreSetTitle()
{
    if (!GetTitle().empty())
    {
        if (!m_pTitle)
        {
            m_pTitleBox->Enable(true);
            m_pTitleBox->AddWidget(m_pTitle = new NNCurses::CLabel(GetTranslation(GetTitle()), false));
            m_pTitle->SetMaxReqWidth(m_iMaxWidth);
        }
        else
            m_pTitle->SetText(GetTranslation(GetTitle()));
    }
}
Ejemplo n.º 22
0
void CInstaller::UpdateButtons(void)
{
    if (m_InstallScreens.empty() || (FirstValidScreen() &&
         !m_InstallScreens[m_CurrentScreen]->HasPrevWidgets()))
        m_pPrevButton->Enable(false);
    else if (!m_bPrevButtonLocked)
        m_pPrevButton->Enable(true);
    
    if (m_InstallScreens.empty() || (LastValidScreen() &&
         !m_InstallScreens[m_CurrentScreen]->HasNextWidgets()))
        m_pNextButton->SetText(GetTranslation("Finish"));
    else
        m_pNextButton->SetText(GetTranslation("Next"));
}
Ejemplo n.º 23
0
void CInstaller::CancelCB(Fl_Widget *w, void *p)
{
    CInstaller *installer = static_cast<CInstaller *>(p);
    
    const char *msg;
    if (installer->Installing())
        msg = GetTranslation("Install commands are still running\n"
                "If you abort now this may lead to a broken installation\n"
                "Are you sure?");
    else
        msg = GetTranslation("This will abort the installation\nAre you sure?");
    
    if (fl_choice(msg, GetTranslation("No"), GetTranslation("Yes"), NULL))
        throw Exceptions::CExUser();
}
Ejemplo n.º 24
0
bool FTransform::DebugEqualMatrix(const FMatrix& Matrix) const
{
	FTransform TestResult(Matrix);
	if (!Equals(TestResult))
	{
		// see now which one isn't equal		
		if (!Scale3DEquals(TestResult.Scale3D, ScalarRegister(0.01f)))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(S)\t%s"), *TestResult.GetScale3D().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(S)\t%s"), *GetScale3D().ToString());
		}

		// see now which one isn't equal
		if (!RotationEquals(TestResult.Rotation))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(R)\t%s"), *TestResult.GetRotation().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(R)\t%s"), *GetRotation().ToString());
		}

		// see now which one isn't equal
		if (!TranslationEquals(TestResult.Translation, ScalarRegister(0.01f)))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(T)\t%s"), *TestResult.GetTranslation().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(T)\t%s"), *GetTranslation().ToString());
		}
		return false;
	}

	return true;
}
void CLuaRadioButton::CoreUpdateLanguage()
{
    TOptions &opts = GetOptions();
    int n = 0;
    for (TOptions::iterator it=opts.begin(); it!=opts.end(); it++, n++)
        m_pRadioButton->SetName(n, GetTranslation(*it));
}
Ejemplo n.º 26
0
CLuaInputField::CLuaInputField(const char *label, const char *desc, const char *val, int max,
                               const char *type) : CBaseLuaWidget(desc), CBaseLuaInputField(label, type), m_pLabel(NULL)
{
    const int inputh = 25;
    m_pPack = new Fl_Pack(0, 0, 0, inputh);
    m_pPack->resizable(NULL);
    m_pPack->type(Fl_Pack::HORIZONTAL);
    m_pPack->spacing(PackSpacing());
    m_pPack->begin();
    
    if (label && *label)
    {
        m_pLabel = new Fl_Box(0, 0, 0, inputh, GetTranslation(label));
        m_pLabel->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
        m_pLabel->labelfont(FL_COURIER); // Use a fixed font, so we can easily calc the width from GetLabelWidth()
    }
    
    if (GetType() == "number")
        m_pInputField = new Fl_Int_Input(0, 0, 0, inputh);
    else if (GetType() == "float")
        m_pInputField = new Fl_Float_Input(0, 0, 0, inputh);
    else
        m_pInputField = new Fl_Input(0, 0, 0, inputh);
    
    m_pInputField->maximum_size(max);
    m_pInputField->callback(InputChangedCB, this);
    m_pInputField->when(FL_WHEN_CHANGED);
    
    if (val && *val)
        m_pInputField->value(val);
    
    m_pPack->end();
    GetGroup()->add(m_pPack);
}
Ejemplo n.º 27
0
std::string InputBox(const std::string &msg, const std::string &init, int max, chtype out)
{
    CDialog *dialog = CreateBaseDialog(TColorPair(COLOR_GREEN, COLOR_BLUE),
                                       TColorPair(COLOR_WHITE, COLOR_BLUE), 50);
    
    CLabel *label = new CLabel(msg, false);
    label->SetMaxReqWidth(MaxW());
    dialog->AddWidget(label);
    
    CInputField *input = new CInputField(init, CInputField::STRING, max, out);
    dialog->StartPack(input, true, true, 1, 0);
    
    CButton *okbutton = new CButton(GetTranslation("OK")), *cancelbutton = new CButton(GetTranslation("Cancel"));
    dialog->AddButton(okbutton, false, false);
    dialog->AddButton(cancelbutton, false, false);

    TUI.AddGroup(dialog, true);
    
    while (dialog->Run())
        ;
    
    std::string ret;
    if (dialog->ActivatedWidget() != cancelbutton)
        ret = input->Value();
    
    delete dialog;
    
    return ret;
}
Ejemplo n.º 28
0
//---------------------------------------------------------------------------
UnicodeString TConfiguration::GetFileInfoString(const UnicodeString & Key,
  const UnicodeString & FileName) const
{
  TGuard Guard(FCriticalSection);

  UnicodeString Result;
  void * Info = GetFileApplicationInfo(FileName);
  SCOPE_EXIT
  {
    if (!FileName.IsEmpty() && Info)
    {
      FreeFileInfo(Info);
    }
  };
  {
    if ((Info != nullptr) && (GetTranslationCount(Info) > 0))
    {
      TTranslation Translation = GetTranslation(Info, 0);
      try
      {
        Result = ::GetFileInfoString(Info, Translation, Key);
      }
      catch (const std::exception & e)
      {
        (void)e;
        DEBUG_PRINTF(L"Error: %s", MB2W(e.what()).c_str());
        Result = L"";
      }
    }
  }
  return Result;
}
Ejemplo n.º 29
0
void CLuaCFGMenu::CoreAddVar(const char *name)
{
    GtkTreeIter iter;
    GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(m_pVarListView)));
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, COLUMN_TITLE, GetTranslation(name),
                       COLUMN_DESC, GetTranslation(GetVariables()[name]->desc.c_str()),
                       COLUMN_VAR, name, -1);
    
    if (m_bInitSelection)
    {
        m_bInitSelection = false;
        GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pVarListView));
        gtk_tree_selection_select_iter(selection, &iter);
    }
}
Ejemplo n.º 30
0
UnicodeString TConfiguration::GetFileFileInfoString(const UnicodeString & AKey,
  const UnicodeString & AFileName, bool AllowEmpty) const
{
  TGuard Guard(FCriticalSection);

  UnicodeString Result;
  void * Info = GetFileApplicationInfo(AFileName);
  SCOPE_EXIT
  {
    if (!AFileName.IsEmpty() && Info)
    {
      FreeFileInfo(Info);
    }
  };
  if ((Info != nullptr) && (GetTranslationCount(Info) > 0))
  {
    TTranslation Translation = GetTranslation(Info, 0);
    try
    {
      Result = ::GetFileInfoString(Info, Translation, AKey, AllowEmpty);
    }
    catch (const std::exception & e)
    {
      (void)e;
      DEBUG_PRINTF("Error: %s", ::MB2W(e.what()).c_str());
      Result.Clear();
    }
  }
  else
  {
    assert(!AFileName.IsEmpty());
  }
  return Result;
}