~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to client/gui-sdl/cma_fe.c

  • Committer: Package Import Robot
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2011-08-28 22:40:00 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: package-import@ubuntu.com-20110828224000-j2r1erewlem25dox
Tags: 2.3.0-1
[ Karl Goetz ]
* New upstream version.
* Fix themes_sdl_use_system_fonts.diff to apply cleanly on 2.3.0
* Massage work_around_unity_induced_breakage.diff to get it
  applying to the new codebase (The patch assumes commits made
  after 2.3.0 was tagged upstream).

[ Clint Adams ]
* Fudge build system to think there is no libtool mismatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
static struct cma_dialog {
52
52
  struct city *pCity;
53
53
  struct SMALL_DLG *pDlg;
54
 
  struct ADVANCED_DLG *pAdv;  
55
 
  struct cm_result *pResult;
 
54
  struct ADVANCED_DLG *pAdv;
56
55
  struct cm_parameter edited_cm_parm;
57
56
} *pCma = NULL;
58
57
 
117
116
    *(int *)pMotion->pScrollBar->data.ptr =
118
117
                pMotion->base + (pMotion->pScrollBar->size.x - pMotion->min);
119
118
    
120
 
    my_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pMotion->pScrollBar->data.ptr);
 
119
    fc_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pMotion->pScrollBar->data.ptr);
121
120
    copy_chars_to_string16(pMotion->pScrollBar->next->string16, cBuf);
122
121
    
123
122
    /* redraw label */
468
467
  /* ---------- */
469
468
  /* create exit button */
470
469
  pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
471
 
                          WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
472
 
  pBuf->string16 = create_str16_from_char(_("Close Dialog (Esc)"), adj_font(12));
 
470
                          WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
 
471
  pBuf->info_label = create_str16_from_char(_("Close Dialog (Esc)"),
 
472
                                            adj_font(12));
473
473
  pBuf->action = cancel_SLD_cma_callback;
474
474
  set_wstate(pBuf, FC_WS_NORMAL);
475
475
  pBuf->key = SDLK_ESCAPE;
597
597
static int run_cma_once_callback(struct widget *pWidget)
598
598
{
599
599
  if (Main.event.button.button == SDL_BUTTON_LEFT) {
600
 
    struct cm_result result;
601
 
  
602
 
    update_city_cma_dialog();  
 
600
    struct cm_result *result;
 
601
 
 
602
    update_city_cma_dialog();
603
603
    /* fill in result label */
604
 
    cm_query_result(pCma->pCity, &pCma->edited_cm_parm, &result);
605
 
    cma_apply_result(pCma->pCity, &result);
 
604
    result = cm_result_new(pCma->pCity);
 
605
    cm_query_result(pCma->pCity, &pCma->edited_cm_parm, result);
 
606
    cma_apply_result(pCma->pCity, result);
 
607
    cm_result_destroy(result);
606
608
  }
607
609
  return -1;
608
610
}
632
634
  output_type_iterate(i) {
633
635
    /* min label */
634
636
    pBuf = pBuf->prev;
635
 
    my_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
 
637
    fc_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
636
638
    copy_chars_to_string16(pBuf->string16, cBuf);
637
639
        
638
640
    /* min scrollbar */
642
644
    
643
645
    /* factor label */
644
646
    pBuf = pBuf->prev;
645
 
    my_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
 
647
    fc_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
646
648
    copy_chars_to_string16(pBuf->string16, cBuf);
647
649
    
648
650
    /* factor scrollbar*/
654
656
  
655
657
  /* happy factor label */
656
658
  pBuf = pBuf->prev;
657
 
  my_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
 
659
  fc_snprintf(cBuf, sizeof(cBuf), "%d", *(int *)pBuf->prev->data.ptr);
658
660
  copy_chars_to_string16(pBuf->string16, cBuf);
659
661
  
660
662
  /* happy factor scrollbar */
664
666
    
665
667
}
666
668
 
667
 
#if 0
668
 
static bool is_worker(const struct city *pCity, int x, int y)
669
 
{
670
 
  return pCma && pCma->pResult && pCma->pResult->worker_positions_used[x][y];
671
 
}
672
 
#endif
673
 
 
674
669
/* ===================================================================== */
675
670
void update_city_cma_dialog(void)
676
671
{
684
679
  bool cma_presets_exist = cmafec_preset_num() > 0;
685
680
  bool client_under_control = can_client_issue_orders();
686
681
  bool controlled = cma_is_city_under_agent(pCma->pCity, NULL);
687
 
  struct cm_result result;
688
 
    
 
682
  struct cm_result *result = cm_result_new(pCma->pCity);;
 
683
 
689
684
  /* redraw window background and exit button */
690
685
  redraw_group(pBuf->prev, pBuf, 0);
691
 
                  
 
686
 
692
687
  /* fill in result label */
693
 
  cm_result_from_main_map(&result, pCma->pCity, TRUE);
694
 
  
695
 
  if(result.found_a_valid) {
696
 
    /* redraw resources */
697
 
    pCma->pResult = &result;
698
 
#if 0    
699
 
    refresh_city_resource_map(pBuf->dst->surface, pBuf->area.x + adj_size(22),
700
 
          pBuf->area.y + adj_size(31), pCma->pCity, is_worker);
701
 
#endif    
702
 
    pCma->pResult = NULL;
703
 
  
 
688
  cm_result_from_main_map(result, pCma->pCity);
 
689
 
 
690
  if(result->found_a_valid) {
704
691
    /* redraw Citizens */
705
692
    count = pCma->pCity->size;
706
693
    
716
703
    dst.x = pBuf->area.x + adj_size(7);
717
704
 
718
705
    for (i = 0;
719
 
      i < count - (result.specialists[SP_ELVIS]
720
 
                   + result.specialists[SP_SCIENTIST]
721
 
                   + result.specialists[SP_TAXMAN]); i++) {
 
706
      i < count - (result->specialists[SP_ELVIS]
 
707
                   + result->specialists[SP_SCIENTIST]
 
708
                   + result->specialists[SP_TAXMAN]); i++) {
722
709
      pText = adj_surf(get_citizen_surface(CITIZEN_CONTENT, i));
723
710
      alphablit(pText, NULL, pBuf->dst->surface, &dst);
724
711
      dst.x += step;
725
712
    }
726
713
    
727
714
    pText = get_tax_surface(O_LUXURY);
728
 
    for (i = 0; i < result.specialists[SP_ELVIS]; i++) {
 
715
    for (i = 0; i < result->specialists[SP_ELVIS]; i++) {
729
716
      alphablit(pText, NULL, pBuf->dst->surface, &dst);
730
717
      dst.x += step;
731
718
    }
732
719
 
733
720
    pText = get_tax_surface(O_GOLD);
734
 
    for (i = 0; i < result.specialists[SP_TAXMAN]; i++) {
 
721
    for (i = 0; i < result->specialists[SP_TAXMAN]; i++) {
735
722
      alphablit(pText, NULL, pBuf->dst->surface, &dst);
736
723
      dst.x += step;
737
724
    }
738
725
 
739
726
    pText = get_tax_surface(O_SCIENCE);
740
 
    for (i = 0; i < result.specialists[SP_SCIENTIST]; i++) {
 
727
    for (i = 0; i < result->specialists[SP_SCIENTIST]; i++) {
741
728
      alphablit(pText, NULL, pBuf->dst->surface, &dst);
742
729
      dst.x += step;
743
730
    }
745
732
  
746
733
  /* create result text surface */
747
734
  pStr = create_str16_from_char(
748
 
        cmafec_get_result_descr(pCma->pCity, &result, &pCma->edited_cm_parm), adj_font(12));
749
 
  
 
735
      cmafec_get_result_descr(pCma->pCity, result,
 
736
                              &pCma->edited_cm_parm), adj_font(12));
 
737
 
750
738
  pText = create_text_surf_from_str16(pStr);
751
739
  FREESTRING16(pStr);
752
740
  
799
787
  
800
788
  /* Run */
801
789
  pBuf = pBuf->prev;
802
 
  if(client_under_control && result.found_a_valid && !controlled) {
 
790
  if(client_under_control && result->found_a_valid && !controlled) {
803
791
    set_wstate(pBuf, FC_WS_NORMAL);
804
792
  } else {
805
793
    set_wstate(pBuf, FC_WS_DISABLED);
806
794
  }
807
 
  
 
795
 
808
796
  /* Run once */
809
797
  pBuf = pBuf->prev;
810
 
  if(client_under_control && result.found_a_valid && !controlled) {
 
798
  if(client_under_control && result->found_a_valid && !controlled) {
811
799
    set_wstate(pBuf, FC_WS_NORMAL);
812
800
  } else {
813
801
    set_wstate(pBuf, FC_WS_DISABLED);
826
814
                pCma->pDlg->pEndWidgetList->prev->prev, 0);
827
815
  
828
816
  widget_flush(pCma->pDlg->pEndWidgetList);
 
817
 
 
818
  cm_result_destroy(result);
829
819
}
830
820
 
831
821
void popup_city_cma_dialog(struct city *pCity)
848
838
  pCma->pCity = pCity;
849
839
  pCma->pDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
850
840
  pCma->pAdv = NULL;
851
 
  pCma->pResult = NULL;  
852
841
  pCity_Map = get_scaled_city_map(pCity);  
853
842
  
854
843
  cmafec_get_fe_parameter(pCity, &pCma->edited_cm_parm);
855
844
  
856
845
  /* --------------------------- */
857
846
    
858
 
  my_snprintf(cBuf, sizeof(cBuf),
 
847
  fc_snprintf(cBuf, sizeof(cBuf),
859
848
              _("City of %s (Population %s citizens) : %s"),
860
849
              city_name(pCity),
861
850
              population_to_text(city_population(pCity)),
876
865
  /* ---------- */
877
866
  /* create exit button */
878
867
  pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
879
 
                          WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
880
 
  pBuf->string16 = create_str16_from_char(_("Close Dialog (Esc)"), adj_font(12));
 
868
                          WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
 
869
  pBuf->info_label = create_str16_from_char(_("Close Dialog (Esc)"),
 
870
                                            adj_font(12));
881
871
  pBuf->action = exit_cma_dialog_callback;
882
872
  set_wstate(pBuf, FC_WS_NORMAL);
883
873
  pBuf->key = SDLK_ESCAPE;
970
960
    
971
961
  /* save as ... */
972
962
  pBuf = create_themeicon(pTheme->SAVE_Icon, pWindow->dst,
973
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
974
 
  
 
963
                          WF_RESTORE_BACKGROUND |WF_WIDGET_HAS_INFO_LABEL);
975
964
  pBuf->action = save_cma_callback;
976
 
  pBuf->string16 = create_str16_from_char(_("Save settings as..."), adj_font(10));
977
 
  
 
965
  pBuf->info_label = create_str16_from_char(_("Save settings as..."),
 
966
                                            adj_font(10));
 
967
 
978
968
  add_to_gui_list(ID_ICON, pBuf);
979
969
  
980
970
  /* load settings */
981
971
  pBuf = create_themeicon(pTheme->LOAD_Icon, pWindow->dst,
982
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
983
 
  
 
972
                          WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
984
973
  pBuf->action = load_cma_callback;
985
 
  pBuf->string16 = create_str16_from_char(_("Load settings"), adj_font(10));
 
974
  pBuf->info_label = create_str16_from_char(_("Load settings"),
 
975
                                            adj_font(10));
986
976
  
987
977
  add_to_gui_list(ID_ICON, pBuf);
988
978
  
989
979
  /* del settings */
990
980
  pBuf = create_themeicon(pTheme->DELETE_Icon, pWindow->dst,
991
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
992
 
  
 
981
                          WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
993
982
  pBuf->action = del_cma_callback;
994
 
  pBuf->string16 = create_str16_from_char(_("Delete settings"), adj_font(10));
995
 
  
 
983
  pBuf->info_label = create_str16_from_char(_("Delete settings"),
 
984
                                            adj_font(10));
 
985
 
996
986
  add_to_gui_list(ID_ICON, pBuf);
997
987
    
998
988
  /* run cma */
999
989
  pBuf = create_themeicon(pTheme->QPROD_Icon, pWindow->dst,
1000
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
1001
 
  
 
990
                          WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1002
991
  pBuf->action = run_cma_callback;
1003
 
  pBuf->string16 = create_str16_from_char(_("Control city"), adj_font(10));
1004
 
  
 
992
  pBuf->info_label = create_str16_from_char(_("Control city"), adj_font(10));
 
993
 
1005
994
  add_to_gui_list(ID_ICON, pBuf);
1006
995
  
1007
996
  /* run cma onece */
1008
997
  pBuf = create_themeicon(pTheme->FindCity_Icon, pWindow->dst,
1009
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
1010
 
  
 
998
                          WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1011
999
  pBuf->action = run_cma_once_callback;
1012
 
  pBuf->string16 = create_str16_from_char(_("Apply once"), adj_font(10));
1013
 
  
 
1000
  pBuf->info_label = create_str16_from_char(_("Apply once"), adj_font(10));
 
1001
 
1014
1002
  add_to_gui_list(ID_ICON, pBuf);
1015
1003
  
1016
1004
  /* del settings */
1017
 
  pBuf = create_themeicon(pTheme->Support_Icon, pWindow->dst,
1018
 
        (WF_RESTORE_BACKGROUND|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
1019
 
  
 
1005
  pBuf = create_themeicon(pTheme->Support_Icon, pWindow->dst,
 
1006
                          WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1020
1007
  pBuf->action = stop_cma_callback;
1021
 
  pBuf->string16 = create_str16_from_char(_("Release city"), adj_font(10));
1022
 
  
 
1008
  pBuf->info_label = create_str16_from_char(_("Release city"), adj_font(10));
 
1009
 
1023
1010
  add_to_gui_list(ID_ICON, pBuf);
1024
1011
  
1025
1012
  /* -------------------------------- */